I am getting an error when trying to return a UIImage fetched from Parse.com for this code below:
-(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;
}
The error is: Incompatible block pointer types sending 'UIImage *(^)(NSData *__strong, NSError *__strong)' to parameter of type 'PFDataResultBlock' (aka 'void (^)(NSData *__strong, NSError *__strong)')
If I remove the UIImage return in the block there is no error. Not sure why this is happening. I am covering all bases by returning nil at the end. Can anyone give me a pointer as to why this is happening please?