Home > DeveloperSection > Forums > Best way to save data on the iPhone
Jayne Spooner
Jayne Spooner

Total Post:21

Posted on    September-21-2015 12:37 AM

 iPhone iPhone  Ios  Objective C 

 1 Reply(s)
 757  View(s)
Rate this:

I was creating an iPhone application at the time of coding i need to save the state of my application.

My problem is that the data persisting across upgrades. Some applications that I was used clearly got this wrong, and so I would not prefer them, so please give me suggestion.

Tarun Kumar

Total Post:214

Posted on    September-21-2015 1:26 AM

The simple way to do exactly this to save:

NSMyUser *obj = [NSMyUser myUser];
[obj setObject:@"TextToSave" forKey:@"keyToFindText"];

To load:

NSMyUser *obj = [NSMyUser myUser];
NSString *textToLoad = [obj stringForKey:@"keyToFindText"];

The important thing is that you do not store very large values in NSMyUser. There's a chance of getting in trouble with apple review if you do.
Generally, user defaults is used for storing short keys and preferences such as the users volume level, wether they want to use game center, or send crash logs.

Modified On Sep-21-2015 01:29:51 AM

Don't want to miss updates? Please click the below button!

Follow MindStick