【发布时间】:2020-09-30 13:03:24
【问题描述】:
我正在react-native-asyncstorage 上进行棕地集成。
在pod文件中,RNCAsyncStorage.h有以下内容:
#import <React/RCTBridgeModule.h>
#import <React/RCTInvalidating.h>
#import "RNCAsyncStorageDelegate.h"
...
@interface RNCAsyncStorage : NSObject <RCTBridgeModule,RCTInvalidating>
...
- (void)multiGet:(NSArray<NSString *> *)keys callback:(RCTResponseSenderBlock)callback;
在我的 AppDelegate.m 中有
@implementation AppDelegate {
__weak RCTBridge *_bridge;
}
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
...
}
在我的 Stuff.m 中,我的方法中有这个:
#import <RNCAsyncStorage/RNCAsyncStorage.h>
....
RNCAsyncStorage *asyncStorage = [self.bridge moduleForClass:[RNCAsyncStorage class]];
[asyncStorage multiGet:@[@"playerQueue"]] callback:^(NSArray *response){
NSObject *count = response[0];
if ([count isKindOfClass:[NSError class]]) {
// Failed to get count
return;
}
// Use count here
}];
但我一直收到错误消息,提示“RNCAsyncStorage”的无可见@interface 声明选择器“multiGet:”。 在头文件和 .m 文件中声明了一个 multiGet 选择器。
我应该说 RNCAsyncStorage 是从 Pods 导入的,但我确实尝试将它们拉入我的项目,但仍然遇到相同的错误。我应该做些什么来解决这个问题?谢谢!
【问题讨论】:
标签: ios react-native asyncstorage