これまでにこのコードを持っているねえ
- (id)initWithDictionary:(NSDictionary *)aDictionary {
self = [super init];
if (!self) {
return nil;
}
_userAvatar = [self getUserAvatar:[aDictionary objectForKey:@"user_avatar"]];
_userId = [aDictionary objectForKey:@"user_id"];
_username = [aDictionary objectForKey:@"username"];
_userEmail = [aDictionary objectForKey:@"user_email"];
return self;
}
- (UIImage *)getUserAvatar:(NSString *)avatarPath {
__block UIImage *avatarImage = [[UIImage alloc]init];
if ([avatarPath length] != 0) {
[[AFFnBAPIClient sharedClient] setDefaultHeader:@"Accept" value:@"image/png"];
[[AFFnBAPIClient sharedClient] getPath:FNB_DOWNLOAD_PATH parameters:[NSDictionary dictionaryWithObject:avatarPath forKey:@"avatar"] success:^(AFHTTPRequestOperation *operation, id image) {
avatarImage = image;
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error");
}];
} else {
UIImage *placeholderImage = [UIImage imageNamed:@"placeholder.png"];
avatarImage = placeholderImage;
}
return avatarImage;
}
私の問題は、非同期要求が終了する前にreturn selfが呼び出されることですが、同期要求なしで要求が終了した状態でselfを返すにはどうすればよいですか?