看下面的方法:
-(void)updateProfile:(Profile *)profile WithJSON:(NSString *)JSON;
{
SBJSON *parser = [[SBJSON alloc] init];
NSDictionary *object = [parser objectWithString:JSON error:nil];
NSNumberFormatter *nf = [[NSNumberFormatter alloc] init];
[nf setPositiveFormat:@"#,##0"];
profile.displayName = [object valueForKey:@"displayName"];
profile.profileURL = [object valueForKey:@"profileURL"];
NSString *rep = [object valueForKey:@"reputation"];
profile.reputation = [[nf numberFromString:rep] intValue];
//[rep release]; <-Why not release?
[nf release];
//[object release]; <-Why not release?
[parser release];
}
我已经注释掉了两行,如果没有,这会给我 EXC_BAD_ACCESS。
有人可以向我解释为什么释放这些对象是错误的吗?