containsValueForKey:
Returns a Boolean value that indicates whether the archive contains a value for a given key within the current decoding scope.
- (BOOL)containsValueForKey:(NSString *)key
Parameters of [NSKeyedUnarchiver containsValueForKey]
- key
- A key in the archive within the current decoding scope. key must not be
nil
.
Return Value
YES
if the archive contains a value for key within the current decoding scope, otherwise NO
.
Example of [NSKeyedUnarchiver containsValueForKey]
- (id)initWithCoder:(NSCoder *)decoder
{
self = [super init];
if (self) {
if ([decoder containsValueForKey:@"sunNeverSet"])
self.sunNeverSet = [NSNumber numberWithBool:
[decoder decodeBoolForKey:@"sunNeverSet"]];
}
return self;
}
Example of [NSKeyedUnarchiver containsValueForKey]
- (id)initWithCoder:(NSCoder *)decoder {
self = [super init];
if (self != nil) {
if ([decoder containsValueForKey:@"objectiveList"]) {
objectiveList = [[decoder decodeObjectForKey:@"objectiveList"] retain];
} else {
objectiveList = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5", nil];
}
}