0

メソッド ブロックにアクセスしようとしていますが、次の方法がわかりません。

__block NSString *username;
PFUser *user = [[self.messageData objectAtIndex:indexPath.row] objectForKey:@"author"];
[user fetchIfNeededInBackgroundWithBlock:^(PFObject *object, NSError *error) {
    username = [object objectForKey:@"username"]; 
    NSLog(@"%@", username); //returns "bob";
}];
NSLog(@"%@", username); //returns null

ブロック外のこのコードから変数 'username' にアクセスするにはどうすればよいですか?

4

4 に答える 4