takm takm - 1 year ago 134
iOS Question

What is [__NSCFString base64String]: unrecognized selector sent to instance?

[__NSCFString base64String]: unrecognized selector sent to instance occurred
While trying to develop push notification.
Here is the entire error log.

-[__NSCFString base64String]: unrecognized selector sent to instance 0x165263e0
2015-07-22 15:52:20.441 xxxx[1623:362933] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString base64String]: unrecognized selector sent to instance 0x165263e0'
*** First throw call stack:
(0x22705fef 0x30da9c8b 0x2270b409 0x22709327 0x22638e78 0x1caa99 0x1c4ba7 0x1bf7ed 0x1bf633 0x1af1d9 0x1ae757 0x1bec3f 0x1c64ed 0x13fdfd 0x260ea37b 0x260eb22d 0x2717d8f3 0x226cb7cb 0x226cb767 0x226c9d69 0x22616201 0x22616013 0x2a0e7201 0x25de2a09 0x145965 0x3135baaf)
libc++abi.dylib: terminating with uncaught exception of type NSException

The following is the source.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

[xxxx startSDKWithAppKey:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxx" host:nil logEnabled:YES sandboxEnabled:NO];

[xxxx setDelegate:self];
[xxxx setSPTag:@"xxxx App"];

[xxxx handleApplication:application didFinishLaunchingWithOptions:launchOptions];

application.applicationIconBadgeNumber = 0;

return YES;

#pragma mark APNS notification
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken

[xxxx handleApplication:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];


Eliminating these parts are well executed.

[xxxx handleApplication:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];

Why do not know if this error occurs.
Please tell me how I should be...

Answer Source

It looks to me like you've added the category header files NSString+Base64.h and NSData+Base64.h but you have not linked-in the corresponding implementation (.m) files.

Add NSString+Base64.m and NSData+Base64.m to the Xcode target and that may well solve your issue.

If, however, those implementation object files are part of a library then you might need to add -ObjC to the Other Linker Flags.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download