Store object as a draft
What is the best way to store some objects as a "Draft". I have a form which one can fill out and than press Save. This should upload the data to the internet. But if the user开发者_JAVA技巧 is offline I would like to save it as a draft so the user can upload it later.
Any best practices? Objects can be images, textfields or ManagedObjects from CoreData.
Save it to CoreData with an ID, and store this ID in NSUserDefaults
when opening the application next time, check if NSUserDefaults
has any IDs, if there is then save to the cloud, otherwise keep the ID in UserDefaults.
Any ID that is stored to cloud then remove from NSUserDefaults
NSUserDefaults
is probably the most efficient place for this kind of task:
[[NSUserDefaults standardUserDefaults] setObject:YourObject forKey:@"Draft1"]
Depending on your object(s) you might want to either save more or less values to the userdefaults.
精彩评论