In the app I'm currently developing i have run into a problem. I have several .plist files that store information. When the app starts it checks one of the plist files (that is empty from the beginning) if it is empty, and if it is it will go to a "user login view". After the login the content of the plist file will be replaced by the username. The reason i did this is because i don't want the user to have to login every time that they start the app. But this doesn't work for me, because every time i restart the app (both on my iphone and xcode simulator) all plist files have been reseted.
Right now I'm using the function:
[fileArray writeToFile:currentUserPath atomically:YES];
But is there any other way to maybe write to a file and letting it stay that way (until i change it), or is it maybe a specific folder i have to put it in to make it work?
Thanks
As @mikle94 said you can use NSUserDefaults.
Here is the equivalent objective-c
code
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:@"someUserName" forKey:@"userLogin"];
Then retrieve this info by
NSString *userName = [userDefaults objectForKey:@"userLogin"];