I want to save a boolean into a file and also I want to know how you would retrieve it again. I mainly want to use this for when the iPhone terminates and finishes launching in their respected methods.
Yes, but how do I save an integer using NSData or at least into a file. That is what I am asking
Jaba
2010-01-06 17:26:27
+1
A:
You can convert a boolean to an NSNumber using the convenience constructor (class method) numberWithBool:.
NSNumber can be persisted by adding it to an NSDictionary and using writeToFile:atomically: to save the dictionary as a property list (plist).
NSNumber objects are also used to represent and persist booleans (as well as integers and floats, but not currency) in Core Data.
gerry3
2010-01-06 17:39:13
+3
A:
An alternative to manually saving to a file is to use NSUserDefaults.
To save:
[[NSUserDefaults standardUserDefaults] setBool:myBool forKey:@"myBool"];
To load:
myBool = [[NSUserDefaults standardUserDefaults] boolForKey:@"myBool"];
DyingCactus
2010-01-06 17:51:29