没有可见的"RNCAsyncStorage"@interface声明选择器



我正在对react原生异步存储进行棕地集成。

在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"的No visible@interface声明了选择器"multiGet:"。在头文件和.m文件中都声明了一个multiGet选择器。

我应该说RNCAsyncStorage是从Pods导入的,但我确实试图将它们引入我的项目中,但仍然得到了相同的错误。我该怎么办才能解决这个问题?谢谢

只是语法错误。有一个额外的],正确的调用是:

[asyncStorage multiGet:@[@"playerQueue"] callback:^(NSArray *response){
NSObject *count = response[0];
if ([count isKindOfClass:[NSError class]]) {
// Failed to get count
return;
}
// Use count here
}];

最新更新