I have a class has 4 NSString variables and 1 UIImage variable. Also I have NSMutable Array that holding several instances of the class. I want to store the data in NSMutalbe array into somewhere in iPhone.开发者_StackOverflow社区 What is the best way for this?
You can use NSUserDefaults to store some data: iPhone - how to save user settings from application? or try any other kind of persistent storage
: iPhone Persistent Storage
Basically, if the data is fairly small (but the uiimages make it seem not small), then you can store it in the prefs. You can't store the array of custom objects, you have to make an nsarray of nsdictionaries, and store that.
If there is more data you should store in a file in the documents folder.
The UIImages - store as PNGs - there is a call to get an image as NSData, then you would have an nsarray of nsdictionaries, and a routine for creating the dict, and one for reading it and making up instances of your classes.
If the images are really large, you are going to want to store the images as files by themselves, and just put the path into the dictionary that you store.
精彩评论