Disable ARC with Xcode 5

戏子无情 提交于 2019-12-01 00:52:20
JeremyP

If you want manual reference counting (using retains and releases) you can disable ARC in the build settings.

Select the project in the project navigator. The editor area should show you a view with four tabs: info, build settings, build phases, build rules. Select build settings.

To the left of those four titles, there should be a drop down list for selecting the target you want. Select the target you don't want ARC for.

Scroll down to find the section titled "Apple LLVM 5.0 - Language - Objective-C". Under there are three settings. The bottom one should be "Objective-C Automatic Reference Counting". Set that to "No" and you will have manual reference counting.

It might be a better option, however, to fix the reported problem. It's better to use ARC than not.

To Fix the error

You say your error occurred on the line where you create the obis array. This means that one or more of the following variables is an int instead of an object:

compteur1, compteur2, compteur3, compteur4, compteur5, nameC1, nameC2, nameC3, nameC4, nameC5

If you want to put an integer into an array, you have to box it as an NSNumber e.g.

NSArray* anArray = [NSArray arrayWithObjects: [NSNumber numberWithInt: 2], nil];

There is a shorthand form of writing that now, which looks like this:

NSArray* anArray =  @[ @(2) ];
Saurabh

Here are the steps I recommend:

  1. select your project or plist
  2. go to build setting
  3. select levels
  4. scroll down to Object-C Automatic Reference Counting as shown in screen shot
  5. select No from drop down against it
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!