Skip to Content
Author's profile photo Kenichi Unnai

#08 SMP3 OData SDK for iOS – Offline APIs

Hi everyone, time to code.


In order to refresh the offline store…

/wp-content/uploads/2014/10/refresh_549014.png

This single line of code does the job.

01  [offlineStore scheduleRefreshWithDelegate:self];

Just like the other delegates so far, we need a new delegate named SODataOfflineStoreRefreshDelegate. In this example it is declared in the same class, so simply set self. This delegate has two mandatory callback methods:

  • offlineStoreRefreshSucceeded: Called when a refresh has finished successfully.
  • offlineStoreRefreshFailed: Called when a refresh has failed.

And two optional callback methods:

  • offlineStoreRefreshStarted: Called when a refresh has started.
  • offlineStoreRefreshFinished: Called when a refresh has finished.

That’s all for the refresh. How about the flush?

/wp-content/uploads/2014/10/flush_549021.png

01  [offlineStore scheduleFlushQueuedRequestsWithDelegate:self];

Yes we have a delegate for this too. It is SODataOfflineStoreFlushDelegate (yes, your wild guess is correct 🙂 ). It has two mandatory callback methods:

  • offlineStoreFlushSucceeded: Called when a flush has finished successfully.
  • offlineStoreFlushFailed: Called when a flush has failed.

And two optional callback methods:

  • offlineStoreFlushStarted: Called when a flush has started.
  • offlineStoreFlushFinished: Called when a flush has finished.

…Hope you’re pleasantly surprised with its simplicity.

However…


Yes, I hear you. The question is “What if the OData Producer fails one of the queued requests during a flush?”


We’ll discuss about it in the next one, stay tuned.



See you in the next blog,

Ken


List of blogs

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Ken,

      Is there any api to know whether there are any pending flush requests in the offline store before calling scheduleFlushQueuedRequestsWithDelegate?

      Regards,

      Dhani

      Author's profile photo Kenichi Unnai
      Kenichi Unnai
      Blog Post Author

      There is a method getRequestQueueIsEmpty in the SODataOfflineStore API which will return a Boolean to indicate whether there is something waiting to be flushed.

      With this you can only tell whether or not there is something waiting to be flushed.  You cannot look directly at the requests.