Help for silver challenge


#1

[code]-(void)encodeRestorableStateWithCoder:(NSCoder *)coder
{
[coder encodeObject:self.circleColor forKey:@“self.circleColor”];

for (int index = 1; index <= [self.subviews count]-1; index++) {
    NSString *encodeKey = [NSString stringWithFormat:@"%dnumber",index];
    UILabel *label =  self.subviews[index];
    [coder encodeObject:label forKey:encodeKey];
    NSLog(@"%@",label);
}

[coder encodeInteger:[self.subviews count] forKey:@"count"];

[super encodeRestorableStateWithCoder:coder];

}

-(void)decodeRestorableStateWithCoder:(NSCoder *)coder
{
UIColor *color = [coder decodeObjectForKey:@“self.circleColor”];

self.circleColor = color;


NSUInteger number = [coder decodeIntegerForKey:@"count"];
NSLog(@"Start decode");
for (int index = 1; index <= number-1; index++) {
    NSString *encodeKey = [NSString stringWithFormat:@"%dnumber",index];
    UILabel *label = [coder decodeObjectForKey:encodeKey];
    NSLog(@"%@",label);
    [self addSubview:label];
}

}
[/code]

Why can’t i decode the coder to get UILabel object while the encoding was successful?