我对 Facebook SDK 3.5.1 有一些问题
我成功获得了 Facebook 访问令牌和用户信息。但是当我尝试使用 FBProfilePictureView 获取用户(我/朋友)的个人资料图像时,我的应用程序总是崩溃。
提供任何线索寻求帮助。
顺便说一句,抱歉英语不好:(
谢谢。
使用 SDK 登录:
NSArray *permissions = @[@"publish_stream", @"publish_actions"];
FBSessionTokenCachingStrategy *tokenCache = [[FBSessionTokenCachingStrategy alloc] initWithUserDefaultTokenInformationKeyName:kFacebookTokenCache];
[FBSession setActiveSession:[[FBSession alloc] initWithAppID:FB_APP_ID permissions:permissions defaultAudience:FBSessionDefaultAudienceEveryone urlSchemeSuffix:nil tokenCacheStrategy:tokenCache]];
[FBSession openActiveSessionWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceFriends allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
// some codes here.
}];
成功获取 FB 令牌后,我想制作自定义 Facebook 好友列表视图控制器。所以我这样尝试:
[[FBRequest requestForGraphPath:@"/me/friends"] startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (error) {
} else {
FBGraphObject *objects = result;
NSLog(@"%@", result);
NSArray *keys = [objects allKeys];
for (NSString *key in keys) {
if ([key isEqualToString:@"data"]) {
self.dataArray = [objects objectForKey:key];
} else if ([key isEqualToString:@"paging"]) {
self.nextPage = [[objects objectForKey:@"paging"] objectForKey:@"next"];
}
}
}
[self.tableView reloadData];
[self hideLoading];
}];
然后 tableView 显示我的朋友:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
... codes here
NSDictionary *user = [self.dataArray objectAtIndex:indexPath.row];
cell.friendName.text = [user objectForKey:@"name"];
cell.profileView.profileID = [user objectForKey:@"id"]; // <<<-- !!!
... returning cell
}
然后砰!
如果我删除一行cell.profileView.profileID = [user objectForKey:@"id"];
我的程序都可以。没有崩溃。但是...** 叹息 **
这是结果。
FBCacheIndex:预期结果101,实际10 2013-06-05 16:15:59.277
ZPad[14403:a007] FBCacheIndex:SQLite 错误:磁盘 I/O 错误 2013-06-05 16:15:59.278
ZPad[14403:a007] * -FBCacheIndex _removeEntryFromDatabaseForKey:, /Users/facebookSDK/src/FBCacheIndex.m:562 中的断言失败 2013-06-05 16:15:59.279
ZPad[14403:a007] *由于未捕获的异常 NSInternalInconsistencyException',导致应用程序终止,原因:''
* First throw call stack: (0x312602a3 0x390d497f 0x3126015d 0x31b35b13 0x280fb1 0x27db95 0x394ec11f 0x394efecf 0x394efdc1 0x394f091d 0x394f0ac1 0x39520a11 0x395208a4) libc++abi.dylib: terminate called throwing an exception