"BOOL type collection item" is not an objective-c object

Who has a key, why am I getting this?

-(void)postPrimaryEMWithEM:(EM *)em exclusive:(BOOL) isExclusive success:(void (^)())onSuccess failure:(void (^)())onFailure { if(self.accessToken) { GenericObject *genObject = [[GenericObject alloc] init]; [[RKObjectManager sharedManager] postObject:genObject path:@"users/update.json" parameters:@{ ... @"em_id" : ObjectOrNull(em.emID), @"exclusive": isExclusive <-- error message 
+6
source share
2 answers

You cannot put a fundamental data type in a dictionary. It must be an object. But you can use [NSNumber numberWithBool:isExclusive] or use the @(isExclusive) syntax:

 [[RKObjectManager sharedManager] postObject:genObject path:@"users/update.json" parameters:@{ ... @"em_id" : ObjectOrNull(em.emID), @"exclusive": @(isExclusive), ... 

I also do not suspect that you used BOOL * as your parameter. You supposedly intended:

 - (void)postPrimaryEMWithEM:(EM *)em exclusive:(BOOL) isExclusive success:(void (^)())onSuccess failure:(void (^)())onFailure { ... } 

Again, BOOL not an object, so the * syntax is supposedly not intended.

+9
source

Remove the pointer ('*') from the BOOL form:

 exclusive:(BOOL*) isExclusive 

and change:

 @"exclusive": isExclusive 

in

 @"exclusive": [NSNumber numberWithBool:isExclusive] 

or

 // Literal version of above NSNumber @"exclusive": @(isExclusive) 

As a note, NSDictionary cannot store primitive types, including Booleans. Therefore, you must encapsulate the value in an object, in this case NSNumber.

+5
source

All Articles