简体   繁体   English

为什么我看到有关NSAutoreleasePool不可用的消息警告?

[英]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.

相关问题 为什么我收到有关我的应用程序委托和CLLocationManageDelegate的警告? - Why am I getting this warning about my app delegate and CLLocationManageDelegate? 为什么我看到有关核心情节的_OBJC_CLASS _ $ _ CPGraphHostingView的错误? - Why am I seeing an error about _OBJC_CLASS_$_CPGraphHostingView with Core Plot? 为什么我看到有关使用LLVM的-falign-loops的编译错误? - Why am I seeing a compilation error about -falign-loops using LLVM? 为什么会看到以下警告:“假定没有匹配方法签名的消息将返回&#39;id&#39;并接受&#39;...&#39;作为参数”? - Why am I seeing the following warning: “Messages without a matching method signature wii be assumed to return 'id' and accept'…'as arguments ”? iPhone:关于NSAutoreleasePool的困惑 - iPhone: Confusion about NSAutoreleasePool 为什么会看到错误“格式不是字符串文字且没有格式参数”? - Why am I seeing the error “Format is not a string literal and no format arguments”? 为什么在显示此表视图时看到崩溃? - Why am I seeing a crash when displaying this table view? 为什么在我的应用程序中看到以下异常? - Why am I seeing the following exception within my application? 为什么我在XCode中收到过时的警告 - Why am I getting a deprecated warning in XCode 为什么在OS 3.1上的应用程序中看不到加载屏幕,但在4.0上却显示? - Why am I not seeing a loading screen in my application on OS 3.1, but I am on 4.0?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM