No visible @interface for 'RNCAsyncStorage' declares the selector

789 views Asked by At

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!

1

There are 1 answers

0
Fancy John On

Just a mistake in syntax. There is an extra ], the correct call is:

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

    // Use count here
}];