5
- (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本身產生,它沒有得到相同的警告:鏘警告:它的初始化過程中存儲到「池」值永遠不會讀
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
很好的答案 – 2015-12-31 12:23:51