简体   繁体   中英

Best way to backUp user's app data

I'm building an app. Just the app, I have no server right now.

The app allows the user to store information (text, a lot of text). And I want to be able to save this somewhere to allow user to restore this data if he changes his phone or if he signs out and signs ins again later or stuff like that.

I'm saving the user's data in the app with CoreData. I don't need sync between different devices because the app can be "logged in" in just one device at a time.

What's the best approach to follow? I have no idea what to do... any tutorial or pdf or something like that will be really useful!

Thanks!

If you want your users to be able to back up and restore manually, you could do this via the Documents directory. Contents of the Documents directory are visible to the user in iTunes > iPhone > Apps > File Sharing. You could have a UI control that copies the data to this directory, then the user could use iTunes to save the data to computer's hard drive. The restore would go in the opposite direction.

Simply take whatever data you want and write it to an NSDictionary or some standard data structure built into Cocoa-touch, and then write that variable to a PList file. And whenever you load the application, you can read this PList file and it will create an NSDictionary identical to the one that you saved, and you can then get all of the necessary information.

Here is a good code example

is it possible to save NSMutableArray or NSDictionary data as file in iOS?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM