Question

My question is simple. When do I receive Memory Warning, Where I should save or retain data or states in order to retrieve in viewDidLoad()?

For example, I got a view with a TextField, the user write an email and then it do something with another App, my App receives a Memory Warning and I handle it with didReceiveMemoryWarning (maybe then, the view will be unload). So, where do I save the "email" in order to set into the TextFiel in viewDidLoad() ? Should I save it with Core Data? SQL?

When I use Android and the S.O. is going to remove a View, the method OnSaveInstaceState is called and I can save the data into a Bundle, Is there any similar object in iOS?

Thanks a lot.

Was it helpful?

Solution

For simple things like that, you could save it in NSUserDefaults:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[[NSUserDefaults standardUserDefaults] setObject:textField.text forKey:@"email"];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top