ios - No visible @interface for 'RNCAsyncStorage' declares the selector
问题描述
I'm working on a brownfield integration on react-native-asyncstorage.
In the pod file, RNCAsyncStorage.h has the following:
#import <React/RCTBridgeModule.h>
#import <React/RCTInvalidating.h>
#import "RNCAsyncStorageDelegate.h"
...
@interface RNCAsyncStorage : NSObject <RCTBridgeModule,RCTInvalidating>
...
- (void)multiGet:(NSArray<NSString *> *)keys callback:(RCTResponseSenderBlock)callback;
And in my AppDelegate.m I have
@implementation AppDelegate {
__weak RCTBridge *_bridge;
}
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
...
}
And in my Stuff.m I have this in my method:
#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
}];
But I kept getting the error saying No visible @interface for 'RNCAsyncStorage' declares the selector 'multiGet:'. There's a multiGet selector being declared in the header file as well as in the .m file.
I should say that RNCAsyncStorage is imported from Pods, but I did try to pull those into my project and still getting the same error. Anything I should do to address this? Thanks!
解决方案
只是语法错误。有一个额外]
的,正确的调用是:
[asyncStorage multiGet:@[@"playerQueue"] callback:^(NSArray *response){
NSObject *count = response[0];
if ([count isKindOfClass:[NSError class]]) {
// Failed to get count
return;
}
// Use count here
}];
推荐阅读
- mpi - installing OpenMPI or MPICH2 in MSYS2-MinGW
- spring-batch - 使用 ClassifierCompositeItemwriter 进行春季批处理,并将所有项目另外写入数据库
- javascript - 给定这个模型,如何使用 updateOne (mongoose) 删除嵌套数组项?
- javascript - How to send post data on success redirect with passport?
- c# - EF Core Migrations: Remove Migrations and Re-Sync Database
- ruby-on-rails - How do I convert the nodes returned when doing a path search in Neo4j?
- mysql - 在mysql中使用insert into时,表名后有一个点是什么意思?
- c# - Why does the null-conditional operator promote thread-safety in C#?
- c - 使用指针按字母顺序对字符串数组进行排序
- c# - 无法将类型“System.DateTime”隐式转换为 IEnumerable