我正在尝试将照片上传到 Parse,但出现了一个奇怪的错误。
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<PFQuery 0xbe68310> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key profilePic.'
我不知道为什么会这样。这是代码。
- (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"];
}
profilePic 类型设置为“文件”,我正在上传 PFFile,所以我不明白问题出在哪里。如果您需要更多信息,请告诉我。