由于 iOS5 xcode4.2 引入了ARC (AutomicReferenceCounting) , 使用xcode4.2 新建项目时,会有一些小小的变化。

NSAutoReleasePool  被 @ {Autoreleasepool / / Code for autoreleasepool } block 取代了。

      新增了__strong , __weak 编译指令。

ios5.0知道你的变量在何时需要release,何时需要autorelease,所以变量不要写成全局的,全局的变量用single去代替。

解决办法:在项目中关闭 ARC 功能,在项目属性中将Object-C Automatic Reference Counting设置为NO即可。否则在编译时,会对 release ,retainCount, retain 等内存相关操作在编译时出现红色警告。

如下图:设置为No即可。

 ios5 xcode 4.2 中 release 显示编译警告或错误的解决方法