据我所知,使用alloc、new或copy创建的任何东西都需要手动释放.例如:
int main(void) {
NSString *string;
string = [[NSString alloc] init];
/* use the string */
[string release];
}
但我的问题是,这难道不是同样有效吗
int main(void) {
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
NSString *string;
string = [[[NSString alloc] init] autorelease];
/* use the string */
[pool drain];
}