2012-01-14 79 views
3

任何想法,爲什麼我得到的消息:爲什麼我看到消息警告NSAutoreleasePool不可用?

NSAutoreleasePool是不可用:自動參考 計數模式

ARC無法禁止「釋放」

的明確消息發送的驗證碼:

#import <UIKit/UIKit.h> 

int main(int argc, char *argv[]) { 

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 
    int retVal = UIApplicationMain(argc, argv, nil, nil); 
    [pool release]; 
    return retVal; 
} 
+1

你的答案在這裏:http://stackoverflow.com/questions/6655842/nsautoreleasepool-is-unavailable – samfisher 2012-01-14 17:02:20

回答

7

是的,你有自動引用計數啓用,它不允許你明確地使用'釋放'。您需要或者禁用ARC或更改您的主要方法是這樣的:

int main(int argc, char *argv[]) 
{ 
    @autoreleasepool { 
     return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 
    } 
} 
0

在targets->構建設置 - >蘋果LLVM Complailer 3.0

Objective-C的垃圾收集支持(改變) -fobjc-gc]