无法弄清楚为什么 profileImage 没有粘住......(我添加了 pImage 只是为了看看它是否与在一个块内......它不是)。
profileImage 只是一个普通的综合属性
@property (strong, nonatomic) UIImageView *profileImage;
-(void)fetchProfileImage
{
__block UIImage *pImage;
dispatch_async(dispatch_get_global_queue(0, 0), ^
{
NSString *url_ = [NSString stringWithFormat:@"http://api.twitter.com/1/users/profile_image/%@", userName];
TWRequest *fetchUserImageRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:url_] parameters:nil requestMethod:TWRequestMethodGET];
[fetchUserImageRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
if ([urlResponse statusCode] == 200)
{
dispatch_async(dispatch_get_main_queue(), ^(void)
{
NSLog(@"[UIImage imageWithData:responseData] = %@", [UIImage imageWithData:responseData]);
pImage = [UIImage imageWithData:responseData];
NSLog(@"pImage = %@", pImage);
self.profileImage.image = pImage;
NSLog(@"self.profileImage.image = %@", self.profileImage.image);
});
}
}];
});
}
日志:
[UIImage imageWithData:responseData] = <UIImage: 0x2685d0>
pImage = <UIImage: 0x2685d0>
self.profileImage.image = (null)