Facebookの名前と画像を同時に取得するのに問題があります。リクエストごとに1つしか受け取れません。
-(void)fbDidLogin{
// Save the access token key info.
[self saveAccessTokenKeyInfo];
// Get the user's info.
[facebook requestWithGraphPath:@"me/?fields=first_name,picture" andDelegate:self];
}
-(void)request:(FBRequest *)request didLoad:(id)result{
if ([result isKindOfClass:[NSArray class]]) {
result = [result objectAtIndex:0];
if ([result objectForKey:@"first_name"]) {
[lblUser setText:[NSString stringWithFormat:@"Welcome %@!", [result objectForKey:@"first_name"]]];
// Show the publish button.
[btnPublish setHidden:NO];
}
}
else {
imageView.image = [UIImage imageWithData:result];
}
}
私が得るエラー
__NSCFDictionary length]: unrecognized selector sent to instance
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary length]: unrecognized selector sent to instance
2つのリクエストでアプローチした場合
-(void)fbDidLogin{
// Save the access token key info.
[self saveAccessTokenKeyInfo];
// Get the user's info.
[facebook requestWithGraphPath:@"me/picture" andDelegate:self];
[facebook requestWithGraphPath:@"me" andDelegate:self];
}
同じ-(void)request:(FBRequest *)request didLoad:(id)resultを使用すると、取得するエラーは次のようになります。
[__NSCFDictionary length]: unrecognized selector sent to instance
では、Facebookの名前と画像の取得をリクエストするにはどうすればよいですか?また、受信データを処理するにはどうすればよいですか?