我正在构建一个用于检索用户个人资料图片的功能。我正在使用 facebook 的 FBSDKGraphRequest 但是一旦我尝试使用检索到的数据将其分配到图片中,就会收到一个我不明白的错误:Variable is not assignable (missing _block type specifier)
我的功能如下:
- (UIImage *)getProfilePicture: (NSString *)ID
{
FBSDKGraphRequest *requestFriends = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me/friends" parameters:@{@"fields": @"name"}];
FBSDKGraphRequestConnection *connection = [[FBSDKGraphRequestConnection alloc] init];
//[connection addRequest:requestFriends completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error)
UIImage* profilePic;
NSString* requestPath = @"me/?fields=name,location,gender,birthday,relationship_status,picture,email,id";
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"picture"}];
[connection addRequest:request completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError* error)
{
NSDictionary* data = (NSDictionary *)result;
NSDictionary* picture = [data objectForKey:@"picture"];
NSDictionary* pictureData = [picture objectForKey:@"data"];
NSString* pictureURL = [pictureData objectForKey:@"url"];
profilePic = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:pictureURL]]];
}];
return profilePic;
}