问题
I get this error, after upgrading both the FB and Parse SDK
to the latest versions. I know that this occurs in my app delegate in the method below.
I have a mixed swift and objective c application, my delegate is written in Objective C and as I am working to the next version I am converting and writing new classes in Swift. If I comment out the handler below the error does not occur, but i get a login failed message, which is what i would expect. After pressing in the login button the Facebook page to authorise the app appears and then the returns to the view controller it is at this point when the method below completes that the error happens.
I understand the meaning of this error, in that a selector is being called on a class that does not have it. The issue I have is that I have checked that all the frameworks are present, and this call appears to be happening from within either the PARSE or Facebook SDKs, so I can't see how to rectify this. can anyone help in why this call fails.
Many thanks.
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
NSLog(@"-------------------------end.of.application.FBSDKApplicationDelegate");
NSLog(@"facebook.Response=%@,url =%@,sourceApp= %@,annotation =%@",application,url,sourceApplication,annotation);
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
// return true;
}
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSData PF_dataFromBase64String:]: unrecognized selector sent to class 0x11343ca48'
*** First throw call stack:
(
0 CoreFoundation 0x0000000113193c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000112e2cbb7 objc_exception_throw + 45
2 CoreFoundation 0x000000011319afad +[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00000001130f113c ___forwarding___ + 988
4 CoreFoundation 0x00000001130f0cd8 _CF_forwarding_prep_0 + 120
5 Chored 0x000000010e2badf5 -[PFDecoder decodeDictionary:] + 658
6 Chored 0x000000010e2bb545 -[PFDecoder decodeObject:] + 130
7 Chored 0x000000010e2bb1b8 __30-[PFDecoder decodeDictionary:]_block_invoke + 94
8 CoreFoundation 0x0000000113192fbc ____NSDictionaryEnumerate_block_invoke421 + 28
9 CoreFoundation 0x0000000113092400 CFBasicHashApply + 128
10 CoreFoundation 0x00000001130cb85b __NSDictionaryEnumerate + 619
11 Chored 0x000000010e2bad5c -[PFDecoder decodeDictionary:] + 505
12 Chored 0x000000010e2bb545 -[PFDecoder decodeObject:] + 130
13 Chored 0x000000010e259631 -[PFCommandNetworkOperation _operationDidFinish] + 259
14 CFNetwork 0x000000011100c0bc __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 69
15 CFNetwork 0x000000011100c060 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 199
16 CFNetwork 0x000000011100c1c7 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 48
17 CFNetwork 0x0000000110edb757 ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 107
18 CFNetwork 0x0000000110fa8de1 ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 273
19 CFNetwork 0x0000000110ec6a26 _ZN19RunloopBlockContext13_invoke_blockEPKvPv + 72
20 CoreFoundation 0x000000011309a354 CFArrayApplyFunction + 68
21 CFNetwork 0x0000000110ec68e7 _ZN19RunloopBlockContext7performEv + 133
22 CFNetwork 0x0000000110ec6726 _ZN17MultiplexerSource7performEv + 256
23 CFNetwork 0x0000000110ec653c _ZN17MultiplexerSource8_performEPv + 72
24 CoreFoundation 0x00000001130c7431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
25 CoreFoundation 0x00000001130bd2fd __CFRunLoopDoSources0 + 269
26 CoreFoundation 0x00000001130bc934 __CFRunLoopRun + 868
27 CoreFoundation 0x00000001130bc366 CFRunLoopRunSpecific + 470
28 CoreFoundation 0x000000011316a661 CFRunLoopRun + 97
29 Foundation 0x0000000112988383 __NSOQSchedule_f + 184
30 libdispatch.dylib 0x00000001141f2614 _dispatch_client_callout + 8
31 libdispatch.dylib 0x00000001141d96a7 _dispatch_queue_drain + 2176
32 libdispatch.dylib 0x00000001141d8cc0 _dispatch_queue_invoke + 235
33 libdispatch.dylib 0x00000001141dc3b9 _dispatch_root_queue_drain + 1359
34 libdispatch.dylib 0x00000001141ddb17 _dispatch_worker_thread3 + 111
35 libsystem_pthread.dylib 0x000000011455f637 _pthread_wqthread + 729
36 libsystem_pthread.dylib 0x000000011455d40d start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
回答1:
The problem isn't yours. It was created by version 1.7.4. I faced it too. This temporary fix is a category on NSData that provides the missing selectors. Here it is a header, NSData+PFData.h
:
@import Foundation;
@interface NSData (PFData)
+ (NSData *) PF_dataFromBase64String: (NSString *) base64;
- (NSString *) PF_base64EncodedString;
@end
Implementation NSData+PFData.m
:
#import "NSData+PFData.h"
@implementation NSData (PFData)
+ (NSData *) PF_dataFromBase64String: (NSString *) base64 {
return [NSData.alloc initWithBase64EncodedString: base64 options: 0];
} // +PF_dataFromBase64String:
- (NSString *) PF_base64EncodedString {
return [self base64EncodedStringWithOptions: 0];
} // -PF_base64EncodedString
@end
You should plan on removing this category when it is no longer necessary, say with Parse v1.7.5.
来源:https://stackoverflow.com/questions/30397475/parse-v1-7-4-and-facebook-sdk-nsinvalidargumentexception-reason-nsdata-pf