For such a small amount of data (26 points) I suggest archiving .
Save to plist using NSKeyedArchiver / NSKeyedUnarchiver . Read the data from the didFinishLaunchingWithOptions delegate and listen to the UIApplicationWillResignActiveNotification to save it.
A NSUserDefaults is a plist with functions designed to store user settings. It is often used instead of the usual plist to save a couple of lines of code, which I think is a bad idea, because you get additional complexity that is not related to your task.
If you want the login to be protected from the fact that someone stole the device, and Keychain is used to conduct a forensic examination. You can use the wrapper and read some articles, comment if you are interested.
If you are looking for additional features, see The best way to store data on iphone , but it doesn't seem to be that way.
Some code to get you started ... Register to call save on app resign:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(saveMyData) name:UIApplicationWillResignActiveNotification object:nil];
On each graphic / dictionary / object, no matter what you want to archive, implement NSCoding:
- (void)encodeWithCoder:(NSCoder*)coder { [coder encodeObject:myIvar forKey:kmyIvar]; } - (id)initWithCoder:(NSCoder*)coder { if((self = [super initWithCoder:coder])) { self.myIvar = [[coder decodeObjectForKey:kmyIvar] retain]; } return self; }
source share