[英]Why am I seeing a message warning about NSAutoreleasePool being unavailable?
Any idea why I get these messages: 知道为什么我收到这些消息:
NSAutoreleasePool is unavailable: not available in automatic reference counting mode NSAutoreleasePool不可用:在自动引用计数模式下不可用
ARC forbids explicit message send of 'release' ARC禁止“发布”的显式消息发送
in this code: 在这段代码中:
#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;
}
This is because you are compiling with Automatic Reference Counting on. 这是因为您正在使用自动引用计数进行编译。 You need to use a different construct with ARC: 您需要在ARC中使用不同的构造:
@autoreleasepool {
// Your code
}
Another option is to turn off ARC for a specific file . 另一个选项是为特定文件关闭ARC 。
Yeah, you have Automatic Reference Counting enabled, which doesn't allow you to explicitly use 'release'. 是的,您启用了自动引用计数,这不允许您明确使用'release'。 You need to either disable ARC or change your main method to look like this: 您需要禁用ARC或将主方法更改为如下所示:
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
Under targets->Build settings->Apple LLVM Complailer 3.0 在targets-> Build settings-> Apple LLVM Complailer 3.0下
Objective-C Garbage Collection (change to ) Supported [ -fobjc-gc] Objective-C垃圾收集(更改为)支持[-fobjc-gc]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.