i am working on a code which requires me to store 60*4 boolean values, the titles for these values are being stored in a plist. i require to manipulate the boolean values runtime and couldnt find a way to update the plist file easily..also using sqlite database for storing the boolean values becomes hectic for such large amount of data...is there any simple way in which i can store and retrive these valuse easily both runtime and after the application starts?
Have a look at this SO question Possible to save an integer array using NSUserDefaults on iPhone?
I don't mean to be a heretic, but there's a simple rule for cases like this: premature optimization is the root of all evil.
60*4 is only 240 booleans. Even if you somehow manage to store them in the worst possible way and take 1k per boolean, that's still only 240k. As long as that's storage rather than RAM, who cares? Why not start with the simplest possible way and fix it when something comes to you later? SQLite would be perfectly fine for this.
If you're close to shipping and have identified this as a problem, by all means ignore this answer. :)
You could use the NSData method of storing the boolean array, but you could also just let cocoa do it naturally:
NSArray* arrayOfBools; // array of 240 NSNumbers, each made with [NSNumber numberWithBool:NO];
then
[[NSUserDefaults standardUserDefaults] setObject:arrayOfBools forKey:@"MyNameForThe240"];
Retrieve them:
NSArray* savedBools = [[[NSUserDefaults standardUserDefaults] objectForKey:"MyNameForThe240"];
You will likely want them in a mutable array:
NSMutableArray* the240ThatCanBeEdited = [NSMutableArray arrayWithArray:savedBools];
Then on quit, save them out with the [[NSUserDefaults standardUserDefaults] setObject:the240ThatCanBeEdited forKey:@"MyNameForThe240"];
--Tom