I want to persist a very simple string. For example "abc". What's the easiest way to do this? I don't want to use a SqlLite database.
iOS includes a storage technology called Archives that few iOS developers know. Archives allow you to encode data with complex relationship graphs into a binary form throug the use of coders and decoders. You can then store this data in files or send it over a network.
Access third-party app data on all your devices When you set up iCloud for a third-party app, your app data is stored in iCloud instead of locally on your device. Because your data is stored in the cloud, it stays up to date anywhere you've set up iCloud for the app, including your iPhone, iPad, iPod touch, and Mac.
In iOS, typically, apps store their data in a folder named Documents , that is saved in a location next to where the app itself is installed (†). It is important to note that you do not need a jailbroken phone to access this folder.
If it is just one single string NSUserDefaults is probably the easiest way.
// write
[[NSUserDefaults standardUserDefaults] setObject:@"abc" forKey:@"MY_PERSISTENT_KEY"];
// read
NSString *abc = [[NSUserDefaults standardUserDefaults] valueForKey:@"MY_PERSISTENT_KEY"];
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