1

I want to create a PFObject and have it saved locally so that if the user quits the app (or heaven forbid, it crashes) the object is still intact on the device BUT not uploaded to the server until the user is ready to submit it. Is this possible?

I know there is the 'saveEventually' method, but my understanding of that is it will at some point save itself to the server automatically, which is not what I want. I want to save locally only and only upload to the server when the user is completed finished.

7
  • Yes, you could save the various components of that PFObject locally then reassemble them into a PFObject once you're ready to save to Parse... Commented Feb 27, 2015 at 16:32
  • Yeah I was hoping Parse had a built in method to just save/cache a new object locally. Hoping to not have to save each property of the object as it can be quite large and contain many types of data. Commented Feb 27, 2015 at 16:36
  • Then you can use Parse's Local Datastore: blog.parse.com/2014/12/09/parse-local-datastore-for-ios Commented Feb 27, 2015 at 16:37
  • I need this often, too. The best thing for me so far has been to wrap my PFObjects in an NSObject that implements NSCoding and then archive them. There's a resource or two (google 'PFObject NSCoding') out there that tries to do this without the NSObject wrapper, but all the stuff I found was hacky and temperamental. I can post my simple-minded solution if you're interested. Commented Feb 27, 2015 at 17:42
  • @LyndseyScott - I don't think you fully understand. I know how to use the local data store, but that is only useful for saving existing items from the Parse server. I want to create a new object locally and have it persist sessions WITHOUT saving it to the Parse server until I want it to. Commented Feb 28, 2015 at 1:34

1 Answer 1

1

If you have enabled the local datastore, calling pinObjectInBackground() on an object should make the object persist between sessions. Every time you make changes to the object that you want to save, call pinObjectInBackground() again. The object will not be saved to the server until you call saveEventually() or some other save function. Any query using fromLocalDatastore() will be able to fetch your locally stored object as long as it is pinned.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.