decodeBoolForKey:
Decodes a Boolean value associated with a given key.
- (BOOL)decodeBoolForKey:(NSString *)key
Parameters of [NSKeyedUnarchiver decodeBoolForKey]
- key
- A key in the archive within the current decoding scope. key must not be
nil
.
Return Value
The Boolean value associated with the key key. Returns
NO
if key does not exist.
Example of [NSKeyedUnarchiver decodeBoolForKey]
- (id)initWithCoder:(NSCoder *)decoder
{
self = [super init];
if(self)
{
name = [[decoder decodeObjectForKey: @"recordName"] copy];
anInt = [decoder decodeIntForKey: @"recordInteger"];
aBool = [decoder decodeBoolForKey: @"recordBool"];
}
return self;
}
Example of [NSKeyedUnarchiver decodeBoolForKey]
NSMutableData *data = [[NSMutableData alloc] initWithContentsOfFile:strPath];
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
self.strCompleteWord = [[unarchiver decodeObjectForKey:@"CompletedWord"] copy];
self.strWordToGuess = [[unarchiver decodeObjectForKey:@"WordToGuess"] copy];
self.arGuessedLetters = [[unarchiver decodeObjectForKey:@"GuessedLetters"] retain];
//self.arGuessedLettersPos = [[unarchiver decodeObjectForKey:@"GuessedLettersPos"] retain];
self.iScore = [unarchiver decodeIntegerForKey:@"Score"];
self.iLives = [unarchiver decodeIntegerForKey:@"Lives"];
self.iRocksFallen = [unarchiver decodeIntegerForKey:@"RocksFallen"];
self.bGameCompleted = [unarchiver decodeBoolForKey:@"GameCompleted"];
self.bGameOver = [unarchiver decodeBoolForKey:@"GameOver"];
[unarchiver finishDecoding];
[data release];