Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning when I fill an array with BOOL

I have this code:

BOOL booleanValue = TRUE;
[arrayZone replaceObjectAtIndex:indexZone withObject:booleanValue];

This code gives me a warning that says:

incompatible integer to pointer conversion: 
sending BOOL to parameter of type 'id'

Why?

like image 976
cyclingIsBetter Avatar asked Dec 10 '22 09:12

cyclingIsBetter


1 Answers

You need to box your BOOL with a NSNUmber like this:

BOOL booleanValue = TRUE;
[arrayZone replaceObjectAtIndex:indexZone withObject:[NSNumber numberWithBool:booleanValue]];

Then, to retrieve your BOOL value, you unbox it using boolValue:

BOOL b = [[arrayZone objectAtIndex:index] boolValue];
like image 75
Nyx0uf Avatar answered Dec 27 '22 23:12

Nyx0uf