尝试创建一个基于 Parse 的 iOS 应用程序,该应用程序使用“共享按钮”和以下代码在后台保存对象:
- (IBAction)share:(id)sender
{
if (self.chosenImageView.image)
{
NSData *imageData = UIImagePNGRepresentation(self.chosenImageView.image);
PFFile *photoFile = [PFFile fileWithData:imageData];
PFObject *photo = [PFObject objectWithClassName:@"Photo"];
photo[@"image"] = photoFile;
photo[@"whoTook"] = [PFUser currentUser];
photo[@"title"] = self.titleTextField.text;
[photo saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error)
{
if (!succeeded)
{
[self showError];
}
}];
}
else
{
[self showError];
}
[self clear];
[self.tabBarController setSelectedIndex:0];
}
获取“NSInvalidArgumentException”,原因:“不能将 nil 用于 PFObject 上的键或值。将 NSNull 用于值。”错误。
请帮忙......