objective-c - ARC不允许将'BOOL'(又名'bool')隐式转换为'id'
问题描述
我正在尝试将来自目标 C 的 BOOL 传递给 react-native。我的代码是:
-(void)editProfile:(BOOL) success
{
[self sendEventWithName:@"editUserProfile" body:success];
}
我不断收到错误:
ARC不允许将'BOOL'(又名'bool')隐式转换为'id'
有什么想法吗?
解决方案
body
参数是一个对象,而不是一个基元。您需要转换success
为 NSNumber。最简单的方法是@()
:
[self sendEventWithName:@"editUserProfile" body:@(success)];
推荐阅读
- twitter-bootstrap - 试图让 Bootstrap 4 导航栏折叠在 Vue 中工作
- ios - 使用 swift 拨打电话无法使用某些号码
- php - 如何使用 php 在 localhost 中修复“ERR_TOO_MANY_REDIRECTS”
- c# - IdentityServer4 基于角色的 Web API 授权与 ASP.NET Core 身份
- python - 缩小代码创建语法问题python
- php - PHP 当数组 =& 本身带有一个键时会发生什么?
- sql-server - 相同外键的多个“ON DELETE CASCADE”约束
- javascript - 在使用 flowtype 的 React 中,我如何只键入某些道具并允许任何其他道具
- c - 二维数组的输出未正确输出
- java - 试图将现有的 spring 应用程序转换为 springboot 应用程序