In versions of Xcode previous to 5, we can disable ARC in the project settings when we create the project. Now ARC is causing this problem for me.
With an property list file, for the reading step, the compiler gives me an error: "implicit conversion of 'int' to 'id' is disallowed with ARC". I did not have this problem with the same code with Xcode 4. In my property list file, The keys are numbers and also in my viewController.m When I disallow ARC for the target, the warning persists.
I don't see how I can add a compiler flag. The code (with French strings):
NSString *error;
NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *plistPath = [rootPath stringByAppendingPathComponent:@"Save.plist"];
NSArray *keys = [NSArray arrayWithObjects:@"valeurCompteur1", @"valeurCompteur2", @"valeurCompteur3", @"valeurCompteur4", @"valeurCompteur5", @"nomCompteur1", @"nomCompteur2", @"nomCompteur3", @"nomCompteur4", @"nomCompteur5", nil];
NSArray *objs = [NSArray arrayWithObjects: compteur1, compteur2, compteur3, compteur4, compteur5, nameC1, nameC2, nameC3, nameC4, nameC5, nil];
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) ];
Here are the steps I recommend:
- select your project or plist
- go to build setting
- select levels
- scroll down to Object-C Automatic Reference Counting as shown in screen shot
- select No from drop down against it