1

I'm trying to upload a photo to Parse and I am getting a strange error.

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<PFQuery 0xbe68310> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key profilePic.'

I can't figure out why this is happening though. Heres the code.

- (IBAction)setProfilePressed:(id)sender {


    PFQuery *query = [PFQuery queryWithClassName:@"Cards"];
    [query whereKey:@"name" containsString:[[PFUser currentUser] objectForKey:@"name"]];


    UIImage *image = [UIImage imageNamed:@"male_user_icon.png"];


    NSData *imageData = UIImagePNGRepresentation(image);

    PFFile *imageFile = [PFFile fileWithName:@"male_user_icon.png" data:imageData];
    [imageFile saveInBackground];


    [query setValue:imageFile forKey:@"profilePic"];


}

The profilePic type is set to "File" and I am uploading a PFFile so i don't understand what the problem is. Let me know if you need any more information.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
ZB-dev
  • 219
  • 3
  • 12
  • Did you bind profilePic as key in the xib?? – Hussain Shabbir Jul 17 '14 at 04:16
  • Please [search on the error](http://stackoverflow.com/search?q=NSUnknownKeyException+this+class+is+not+key+value+coding-compliant+for+the+key). There are countless topics covering this issue. – rmaddy Jul 17 '14 at 04:40
  • It simply says key `profilePic` doesn't exist, did you try to `[query includeKey:@"profilePic"]` before setting the value for it? – iphonic Jul 17 '14 at 04:42

1 Answers1

0

This error occurs if dictionary doesn't contain that key value.In your case may be there is no key as profilePic for PFQuery class or dictionary.

iphonic
  • 12,615
  • 7
  • 60
  • 107
poojathorat
  • 1,200
  • 2
  • 9
  • 19
  • It is a column in my Parse database though, even when i "includeKey" as prolilePic it still gives the same error. – ZB-dev Jul 17 '14 at 15:01