我使用Facebook for iOS。通过Graph Api我可以毫无问题地获得用户的数据。从用户的数据我得到应用程序范围的用户ID。然后我尝试获取用户的图片但应用程序崩溃了。我尝试使用[FBRequestConnection startWithGraph:@“/ me / picture”...]和[FBRequestConnection startWithGraph:@“/(来自用户数据的app id)/ picture”......]但仍然崩溃了。为什么呢?
2014-06-02 16:16:51.669 testapp[448:60b] -[NSNull dataUsingEncoding:]: unrecognized selector sent to instance 0x19f8068
2014-06-02 16:16:51.679 testapp[448:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull dataUsingEncoding:]: unrecognized selector sent to instance 0x19f8068'
*** First throw call stack:
(
0 CoreFoundation 0x018ac1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0162b8e5 objc_exception_throw + 44
2 CoreFoundation 0x01949243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0189c50b ___forwarding___ + 1019
4 CoreFoundation 0x0189c0ee _CF_forwarding_prep_0 + 14
5 testapp 0x00022721 +[FBUtility simpleJSONDecode:error:] + 42
6 testapp 0x0000a75e -[FBRequestConnection parseJSONOrOtherwise:error:] + 69
7 testapp 0x0000a5a0 -[FBRequestConnection parseJSONResponse:error:statusCode:] + 1256
8 testapp 0x00009e04 -[FBRequestConnection completeWithResponse:data:orError:] + 666
9 testapp 0x00007564 __68-[FBRequestConnection startWithCacheIdentity:skipRoundtripIfCached:]_block_invoke + 201
10 testapp 0x00045fbc -[FBURLConnection invokeHandler:error:response:responseData:] + 49
11 testapp 0x00045ec7 -[FBURLConnection logAndInvokeHandler:response:responseData:] + 414
12 testapp 0x00046442 -[FBURLConnection connectionDidFinishLoading:] + 248
13 Foundation 0x013f4e49 ___NSURLConnectionDidFinishLoading_block_invoke + 40
14 Foundation 0x0138b7e1 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 62
15 Foundation 0x01213f5e -[NSURLConnectionInternalConnection invokeForDelegate:] + 119
16 Foundation 0x01213ec6 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 208
17 Foundation 0x01213dd8 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 76
18 Foundation 0x01214188 _NSURLConnectionDidFinishLoading + 43
19 CFNetwork 0x064aa69f ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 111
20 CFNetwork 0x064a83de ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 104
21 CoreFoundation 0x0184dc69 CFArrayApplyFunction + 57
22 CFNetwork 0x06411441 _ZN19RunloopBlockContext7performEv + 155
23 CFNetwork 0x064f33f4 _ZThn16_N19RunloopBlockContext24multiplexerClientPerformEv + 20
24 CFNetwork 0x06411257 _ZN17MultiplexerSource7performEv + 299
25 CFNetwork 0x0641106c _ZN17MultiplexerSource8_performEPv + 76
26 CoreFoundation 0x0183577f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
27 CoreFoundation 0x0183510b __CFRunLoopDoSources0 + 235
28 CoreFoundation 0x018521ae __CFRunLoopRun + 910
29 CoreFoundation 0x018519d3 CFRunLoopRunSpecific + 467
30 CoreFoundation 0x018517eb CFRunLoopRunInMode + 123
31 GraphicsServices 0x038a05ee GSEventRunModal + 192
32 GraphicsServices 0x038a042b GSEventRun + 104
33 UIKit 0x002ebf9b UIApplicationMain + 1225
34 testapp 0x00003b2d main + 141
35 libdyld.dylib 0x01ef3701 start + 1
36 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
谢谢!
答案 0 :(得分:2)
我想这是因为如果你查询/me/picture
,你就不会处理Facebook正在发送的http重定向。如果您只想要图片的网址,请使用文档中所述的/me/picture?redirect=false
:https://developers.facebook.com/docs/graph-api/reference/v2.0/user/picture/#read
否则添加一些代码来处理http重定向。
答案 1 :(得分:0)
我解决了我的问题。我发送像Bool这样的重定向参数。当我改为字符串时,它开始工作。
感谢。