NSUserDefaults is very useful, if you want to save less data and want to access that data whenever you open the application. This data does not delete even after closing the app.
To save data in NSUserDefaults
NSUserDefaults *usr = [NSUserDefaults standardUserDefaults];
[usr setObject:userNameText.text forKey:@"user"];
[usr setObject:passwordText.text forKey:@"password"];
[usr synchronize];
To access data from NSUserDefaults
NSUserDefaults *usr = [NSUserDefaults standardUserDefaults];
NSString *user = [usr objectForKey:@"user"];
NSString *pass = [usr objectForKey:@"password"];
0 Comment(s)