我尝试将react代码与现有的objective-C API绑定在一起。在我的代码中,我有:
#import "RcpRfidApi.h"
@implementation RcpRfidApi
// The React Native bridge needs to know our module
RCT_EXPORT_MODULE(RcpRfidApi);
- (NSDictionary *)constantsToExport {
return @{@"greeting": @"Welcome to the DevDactic\n React Native Tutorial!"};
}
RCT_EXPORT_METHOD(setReaderPower:(bool)on:(RCTResponseSenderBlock)callback) {
callback(@[[NSNull null], [NSNumber numberWithBool:on]]);
}
@end
但是当我尝试在react上调用我的函数时,我有一个错误
方法中的
未知参数类型'_Bool‘....扩展RCTConvert以支持此类型。
发布于 2018-07-27 03:34:50
对于布尔值,RCT_EXPORT_METHOD()只能支持BOOL或NSNumber。https://facebook.github.io/react-native/docs/native-modules-ios
发布于 2018-06-02 02:49:43
如果你有这个问题,你可能需要在你的项目中添加一个库。进入: Xcode >你的项目>构建阶段>使用库链接二进制文件。
在我的例子中,需要的是苹果的ExternalAccesory.framework。
https://stackoverflow.com/questions/50622961
复制相似问题