如何从Parse中删除图像?

时间:2014-11-01 11:22:45

标签: objective-c xcode parse-platform

我想删除/覆盖给定用户的Parse照片。你会帮我吗?因为我编写了代码,我总是返回错误102

PFQuery *query = [PFQuery queryWithClassName:@"User"];

[query whereKey:@"User" equalTo:[PFUser currentUser]];

[query includeKey:@"Foto"];

[query whereKeyExists:@"Dev.png"];   //Change this condition to fetch the row.

[query getFirstObjectInBackgroundWithBlock:^(PFObject *object1, NSError *error)
 {
     if (!error) {
         NSLog(@"Successfully retrieved: %@", object1);

         //This might work as I searched for this deleting image but there is no method to do so.
         //So a way would be is to get that object and then setting nil value in it's place.
         //Else if u want to delete the entire row then u could simply type, [object deleteInBackground]
         object1[@"Foto"] = [NSNull null];
     }
     else
     {
         NSLog(@"Error: %@", [error localizedDescription]);
     }
 }];

这是我的表:

http://cl.ly/YKCa

1 个答案:

答案 0 :(得分:1)

更改此行:

[query whereKey:@"User" equalTo:[PFUser currentUser]];

以下行:

[query whereKey:@"username" equalTo:[PFUser currentUser]];