3
我有一個使用ARC的iOS項目,而且我收到了與創建應用程序的@autoreleasepool相關的錯誤。@autoreleasepool @ token之前的期待表達式
在main.m文件我有一小段代碼使得:
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, @"MyAppDelegate");
}
}
我收到錯誤消息:
錯誤:前 '@' 標記
預期表達但是,如果我恢復到創建autoreleasepool的舊樣式:
#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;
}
I收到在IDE中具體涉及ARC各種錯誤:
- NSAutoreleasePool是不可用:自動引用計數模式
- ARC不可forbitds「釋放」
然而,當我試圖明確的消息發送建立,它建立成功。
衝突在哪裏?
我怎樣才能讓它使用創建自動發佈池的新風格?
自動釋放池錯誤:你用'gcc'(而不是'clang')編譯代碼嗎? ARC錯誤:那裏的編譯器是正確的。 – 2012-12-04 17:34:39
您可能想要選擇左側面板頂部的目標,然後點擊「驗證設置」按鈕。 – Rob
import your appDelegate,並將'@「MyAppDelegate」'更改爲'NSStringFromClass([MyAppDelegate class]' – AMayes