首页 > 解决方案 > ARC不允许将'BOOL'(又名'bool')隐式转换为'id'

问题描述

我正在尝试将来自目标 C 的 BOOL 传递给 react-native。我的代码是:

-(void)editProfile:(BOOL) success
{
  [self sendEventWithName:@"editUserProfile" body:success];
}

我不断收到错误:

ARC不允许将'BOOL'(又名'bool')隐式转换为'id'

有什么想法吗?

标签: objective-creact-native

解决方案


body参数是一个对象,而不是一个基元。您需要转换success为 NSNumber。最简单的方法是@()

[self sendEventWithName:@"editUserProfile" body:@(success)];

推荐阅读