Parse: How get all saveEventually tasks

176 Views Asked by At

I'm using Parse in my iOS app. In my app I'm using a lot of saveEventually() functions to store data in Parse without there needing to be an internet connection available. I know that saveEventually() returns a BFTask object. It is possible to get all the tasks created in order to check their status in any given moment? Also, could this same technique be used after an app restart? Thanks!

1

There are 1 best solutions below

7
On

Parse is using Boltz framework, which in return, you will have a BFTask object upon completion.

Example:

    yourPFObject.saveEventually().continueWithBlock {
          (task: BFTask!) -> BFTask in
       if task.isCancelled() {
           // the save was cancelled.
       } else if task.error() {
        // the save failed.
       } else {
          // the object was saved successfully.
          var object = task.result() as PFObject
       }
    }

With this in mind, you can check their status by storing the completed task in coredata. In appDelegate applicationDidBecomeActive or didFinishLaunchingWithOptions, you can attempt to retrieve them from coredata depending on your logic.

Of course if you want to just keep track on the status, you can keep in a dictionary and stores in NSUserDefault. It is completely up to your choice and needs.

More example can be found in this link : https://github.com/BoltsFramework/Bolts-iOS