我正在尝试从parse.com检索图像,但不知道如何!

我使用以下代码将图像保存到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");
    }
}];


现在我想找回相同的图像并将其保存在imageView中,我该怎么做?

最佳答案

检查getDataInBackgroundWithBlock

PFUser *user = [PFUser currentUser];
PFFile *userImageFile = user[@"imageFile"];
[userImageFile getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {
    if (!error) {
        UIImage *image = [UIImage imageWithData:imageData];
    }
}];

关于ios - 在解析中从用户类检索图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25184956/

10-10 13:02