user2102538
user2102538

Reputation: 39

I want to save the app so when the user, exits, the uitextfields don't erase to text when the user comes back

I want to save the app so when the user, exits, the uitextfields don't erase to text when the user comes back.

When the app is terminated, it erases all the data in the uitextfields.

what do I do?

Upvotes: 0

Views: 79

Answers (3)

Asa
Asa

Reputation: 1466

If you just need the text and not the whole uitextfield object you can put all the fields in a NSDictionary and write them as a plist. There is a a lot of support for this strategy and it may be simplest.

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/Reference/Reference.html

Upvotes: 0

abdus.me
abdus.me

Reputation: 1819

You should save all the values to NSUserDefaults against a key that represents corresponding textFiled. And in appDidFinishLaunching method you should clear all the values. So that when user open the app from terminated state all values gets cleared and display empty textFields.

Upvotes: 1

Rob
Rob

Reputation: 16002

There are lot of alternatives, using serialization and its read/write methods. I think you should have a look at this link : http://cocoaheads.byu.edu/wiki/nscoding.

Upvotes: 1

Related Questions