Try the search, it's linked to some great forums

Friday, November 13, 2015

NSUserDefaults - Persisting data & passing it around viewCOntrollers

This is a very simple way to pass parameters between various views.

1st in the appDelegate.m file add;
// NSUserDefault setup for passing info around the app the starting default values.
        [[NSUserDefaults standardUserDefaults] setInteger:0     forKey:@"list_filtered"];
        [[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"selected_spreadsheet"];
        [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"selected_map_type"];
        [[NSUserDefaults standardUserDefaults] setObject:@"ALL" forKey:@"selected_driver"];
        [[NSUserDefaults standardUserDefaults] setObject:@"initialString" forKey:@"selected_plist"];
        [[NSUserDefaults standardUserDefaults] setObject:@"initialDictionary" forKey:@"selected_member"];
        [[NSUserDefaults standardUserDefaults] setObject:@"selectedIndexPath" forKey:@"selected_indexPath"];
       
// sync the defaults to disk
        [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
        [[NSUserDefaults standardUserDefaults] synchronize];