I am trying to retrieve an image from parse.com, but can't figure out how!
I used this code to save image to the user class in parse.com:
NSData *imageData = UIImageJPEGRepresentation(imageView.image, 1.0);
imageFile = [PFFile fileWithName:@"profilePic" data:imageData];
PFUser *user = [PFUser currentUser];
[user setObject:imageFile forKey:@"imageFile"];
[user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded) {
NSLog(@"saved");
}
}];
Now I want to retrieve the same image back and se it in the imageView
, how can I do that?
Check getDataInBackgroundWithBlock
PFUser *user = [PFUser currentUser];
PFFile *userImageFile = user[@"imageFile"];
[userImageFile getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {
if (!error) {
UIImage *image = [UIImage imageWithData:imageData];
}
}];