I want to store an NSString variable, that I receive from a JSON request, for future use. So when the user loads the app again, it loads that value (an NSString) that I stored.
What is the best way to store that kind of information?
NSUserDefaults is what you're looking for.
Save string:
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setObject:theStringToSave forKey:@"keyToLookupString"];
[prefs synchronize];
Retrieve string:
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSString *theSavedString = [prefs stringForKey:@"keyToLookupString"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With