0
votes

The following code generates compiler warning (below the code)

NSUInteger positionat = [_bhkButtons indexOfObject:sender];
BOOL val = (BOOL) [_searchModel.BHkNo objectAtIndex:positionat];
val = !val;

[_searchModel.BHkNo insertObject:val atIndex:positionat];

Incompatible integer to pointer conversion 'BOOL' (aka 'signed char') to parameter of type 'id'

I'm a newbie to Objective - C. Please help.

1

1 Answers

4
votes

Since BOOL is a primitive data type and arrays take in objects, you have to box/wrap the BOOL variable. You can use the NSNumber class for the same as shown below.

[_searchModel.BHkNo insertObject:[NSNumber numberWithBool:val] atIndex:positionat];