I use Facebook for iOS. I get user's data without problem by Graph Api. From user's data I get app-scoped user id. Then I try get user's picture but application crashed. I tried use [FBRequestConnection startWithGraph:@"/me/picture" ...] and [FBRequestConnection startWithGraph:@"/(app id from user's data)/picture" ...] but still crashed. Why?
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)
Thanks!
I guess this is because you don't handle the http redirect Facebook is sending if you query /me/picture
. If you just want the URL of the picture, use /me/picture?redirect=false
as stated in the docs: https://developers.facebook.com/docs/graph-api/reference/v2.0/user/picture/#read
Otherwise add some code to handle http redirects.
I resolved my problem. I send redirect parameter like Bool. When I change to string it begin working.
Thanks.
User contributions licensed under CC BY-SA 3.0