我目前正在使用新的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