I am new in programming and i have one problem. I create app, with two views. First is tableviewcontroller and second is view controller. from second view i sending data into my tableview trough perepareForSegue method. My data (Strings) are NSMutableArray and this MutableArray i want to save into UsedDefault after my app didEnterBackgoung in appDelegate.m Then i want to load it back, but nothing happened. I put my code in appDidBecomeActive in appDelegate.m and i already try write it in my first view viewDidLoad, but no action. My MuttableArray is still empty, after new app start.
here is my code:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSUserDefaults*defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:self.flipsideView.zoznamFunkcii forKey:@"NSMutableArray"];
[defaults synchronize];
}
flipsideView is my first View and zoznamFunkcii is my NSMuttable array
and this is my load method:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
NSUserDefaults*defaults = [NSUserDefaults standardUserDefaults];
self.flipsideView.zoznamFunkcii = [NSMutableArray arrayWithArray:[defaults objectForKey:@"NSMutableArray"]];
}
Can anyone help me with that? I don't know why it not work.