【发布时间】:2015-02-23 10:29:53
【问题描述】:
在尝试返回从 Parse.com 获取的 UIImage 以获取以下代码时出现错误:
-(UIImage *)getUserImageForUser:(PFUser *)user {
PFFile *userImageFile = user[@"profilePic"];
[userImageFile getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {
if (!error) {
UIImage *image = [UIImage imageWithData:imageData];
[self.images setObject:image forKey:user.username];
return image;
}
}];
return nil;
}
错误是:不兼容的块指针类型将'UIImage *(^)(NSData *__strong, NSError *__strong)'发送到'PFDataResultBlock'类型的参数(又名'void (^)(NSData *__strong, NSError *__strong)')
如果我删除块中的 UIImage 返回,则没有错误。不知道为什么会这样。我通过在最后返回 nil 来覆盖所有基础。谁能告诉我为什么会这样?
【问题讨论】:
标签: ios objective-c xcode parse-platform