我目前正在使用新的Facebook SDK,我有一個很奇怪的問題。我有一個視圖控制器,名爲FacebookExplorerTableViewController在我viewDidLoad中我有以下的代碼:Facebook sdk iOS註銷錯誤
if(appDelegate.session.isOpen)
{
[self receiveAlbums];
}
else
{
appDelegate.session = [[FBSession alloc] init];
appDelegate.session = [FBSession sessionOpenWithPermissions:nil completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
NSLog(@"opened session");
if(!error) [self receiveAlbums];
else NSLog(@"error: %@",error);
}];
}
當我運行它,一切都很好。不過,我還有一個視圖控制器,名爲SharingSettingsTableViewController在那裏我可以選擇退出:
[appDelegate.session closeAndClearTokenInformation];
當我想退出,我得到的Xcode崩潰:
2012-08-09 21:29:19.683 My Albums[2197:17903] opened session
2012-08-09 21:29:19.684 My Albums[2197:17903] requesting albums
2012-08-09 21:29:19.695 My Albums[2197:17903] access token: (null)
2012-08-09 21:29:19.697 My Albums[2197:17903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(0x1b6d022 0x1f56cd6 0x1aac7db 0x1ac4e86 0x757a5 0x754f4 0xa17e2 0x9ef39 0x676f9 0x92c3f1 0x1b6ee99 0x55514e 0x5550e6 0x5fbade 0x5fbfa7 0x5fb266 0x57a3c0 0x57a5e6 0x560dc4 0x554634 0x232eef5 0x1b41195 0x1aa5ff2 0x1aa48da 0x1aa3d84 0x1aa3c9b 0x232d7d8 0x232d88a 0x552626 0x21ed 0x2155)
terminate called throwing an exception
好像我跑再次完成塊!控制檯中的「請求相冊」來自receiveAlbums。
爲什麼此完成塊再次運行?當我去設置視圖控制器,我已經釋放FacebookExplorerTableViewController!這如何運行,我怎麼能擺脫錯誤? :)
在此先感謝!
是你所有的FB SDK API設置?還有更多的代碼需要,你還沒有設置你的訪問令牌或到期日期。 – MCKapur 2012-08-10 00:52:19