NSAutoreleasePool报错

NSAutoreleasePool' is unavailable: not available in automatic reference counting mode

 

错误原因:

阅读的书籍用的是老版本的Xcode,而自己使用的是Xcode5,新版本中苹果引入了自动记算引用数的功能,所以老的项目中

NSAutoreleasePool  * pool = [[NSAutoreleasePool alloc] init];是报错的,必须把arc(auto-reference-command)关闭才行,方法如下:

Build settings--->Apple LLVM compiler 3.0- Language--->Objective-C Automatic Reference Counting 将YES改为NO。

如果是ios5 需要在main的头部引入 #import "AppDelegate.h" 才可以解决。

 

新版本:

@autoreleasepool {

        // insert code here...

    }

posted on 2014-05-02 08:52  orientwolf  阅读(211)  评论(0编辑  收藏  举报