ios – “BOOL类型的集合元素”不是Objective-c对象

前端之家收集整理的这篇文章主要介绍了ios – “BOOL类型的集合元素”不是Objective-c对象前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
任何人都知道为什么我得到这个?
  1. -(void)postPrimaryEMWithEM:(EM *)em
  2. exclusive:(BOOL) isExclusive
  3. success:(void (^)())onSuccess
  4. failure:(void (^)())onFailure {
  5.  
  6.  
  7. if(self.accessToken) {
  8.  
  9.  
  10. GenericObject *genObject = [[GenericObject alloc] init];
  11.  
  12. [[RKObjectManager sharedManager] postObject:genObject
  13. path:@"users/update.json"
  14. parameters:@{
  15. ...
  16. @"em_id" : ObjectOrNull(em.emID),@"exclusive": isExclusive <-- error message

解决方法

您不能将基本数据类型放在字典中.它必须是一个对象.但您可以使用[NSNumber numberWithBool:isExclusive]或使用@(isExclusive)语法:
  1. [[RKObjectManager sharedManager] postObject:genObject
  2. path:@"users/update.json"
  3. parameters:@{
  4. ...
  5. @"em_id" : ObjectOrNull(em.emID),@"exclusive": @(isExclusive),...

我也不怀疑你打算用BOOL *作为参数.你可能想要:

  1. - (void)postPrimaryEMWithEM:(EM *)em
  2. exclusive:(BOOL) isExclusive
  3. success:(void (^)())onSuccess
  4. failure:(void (^)())onFailure {
  5. ...
  6. }

同样,BOOL不是一个对象,因此*语法可能不是预期的.

猜你在找的iOS相关文章