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];

Thursday, November 5, 2015

Plist notes

For reading a Plist you need to;
// Loads file locally from either sheet
    NSBundle *mainBundle = [NSBundle mainBundle];
    NSURL *fileURL = [[NSURL alloc] init];

    fileURL = [mainBundle URLForResource:@"SCWaveDistributionListCurrent"    withExtension:@"plist"];

or just read Apple's docs N:
- URLForResource:withExtension:
Returns the file URL for the resource identified by the specified name and file extension. And I think it will read CSV files directly & with lots less hastle.