对于下面的代码,1 - 从getFoo返回的对象上需要保留; 2 - 是方法func中foo所需的版本吗?是否需要从autorelease对象上保留的参考版本?
- (NSString *)getFoo {
return [[[NSString alloc] initWithString:@"foo"] autorelease];
}
- (void)func {
// ??? is the retain needed?
NSString *foo = [[self getFoo] retain];
// use foo
// ??? is the release needed?
[foo release];
}