2

What is the proper way to save parse objects locally? I placed them in an NSMutableDictionary and tried saving them with NSUserDefaults but that failed with this error, "Attempt to set a non-property-list object as an NSUserDefaults value".

I want to upload my object to Parse and save locally too. Kind of like caching it. I know that parse offers query caching but I need to cache when uploading too, not just when querying.

If it makes a difference, the items inside my pfobject are strings and piffles (images).

I would appreciate if somebody could point me in the right direction.

3 Answers 3

4

parse has added this feature on 9th December for iOS http://blog.parse.com/2014/12/09/parse-local-datastore-for-ios/

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

2 Comments

One question, can we use parse to store data ONLY locally?
I guess yes but I am not aware how! Moreover parse is now open source we can do anything with it
2

Only property lists can be saved into NSUserDefaults. Property list types are following: NSArray, NSDictionary, NSString, NSData, NSDate, NSNumber (see property lists description).

If some class conforms to the NSCoding protocol then it can be serialized into NSData and thus saved into NSUsedDefaults (see for example the Storing NSColor in User Defaults article).

But the PFObject class doesn't conform to the NSCoding protocol, so there is no way to serialize it into NSData and save to user defaults.

However, as I understood, you can create NSDictionary from PFObject; you can save NSDictionary to NSUserDefaults and later restore PFObject from the saved NSDictionary.

1 Comment

One question, can we use parse to store data ONLY locally?
1

There's no proper way to do this right now. Local Data Store was added to Android on 4/30/2014 and will be arriving for iOS at some point soon.

You should not do this, because it could definitely break after a new SDK release, but I did find a hacky way to do this until then... https://gist.github.com/gfosco/ac6b5ebb42791ced0932

2 Comments

One question, can we use parse to store data ONLY locally?
You can... That was one of the things I thought was very cool, using LDS to make offline-only apps easier.

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.