【发布时间】:2011-09-11 08:23:18
【问题描述】:
- (void)main {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // Warning goes here
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
while (YES) {
NSAutoreleasePool *subPool = [[NSAutoreleasePool alloc] init];
[runLoop run];
[subPool drain];
}
[pool drain];
}
我不明白为什么这段代码会收到这样的警告,尤其是当它与 main.m 中由 Xcode 本身生成的 main 函数几乎完全相同的结构时,它没有收到相同的警告:
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
【问题讨论】:
标签: objective-c ios clang