對於下面的代碼,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];
}