encodeBool :forKey:
Encodes a given Boolean value and associates it with a given key.
- (void)encodeBool:(BOOL)boolv forKey:(NSString *)key
Parameters of [NSKeyedArchiver encodeBool]
- boolv
- The value to encode.
- key
- The key with which to associate boolv. This value must not be
nil
.Example of [NSKeyedArchiver encodeBool]-(void) encodeWithCoder: (NSCoder *) encoder { [encoder encodeObject: name forKey: @"recordName"]; [encoder encodeInt: anInt forKey: @"recordInteger"]; [encoder encodeBool: aBool forKey: @"recordBool"]; }
Example of [NSKeyedArchiver encodeBool]- (void)saveState { NSMutableData *data = [NSMutableData data]; NSKeyedArchiver *coder = [[[NSKeyedArchiver alloc] initForWritingWithMutableData:data] autorelease]; [coder encodeBool:myBoolean forKey:@"MyBoolean"]; [coder encodeObject:myObject forKey:@"MyObject"]; [coder finishEncoding] // Save the data somewhere, probably user defaults... }