我是解析新手,正在尝试创建一个将用户链接到他/她的图片的 PFRelation。这是我的代码:
NSData *imageData = UIImagePNGRepresentation(myImage);
PFFile *imageFile = [PFFile fileWithName:@"image.png" data:imageData];
PFObject *pic = [PFObject objectWithClassName:@"Pics"];
//[pic setObject:imageFile forKey:@"Image"];
pic[@"Image"] = imageFile;
PFUser *user = [PFUser currentUser];
PFRelation *relation = [user relationForKey:@"myPhotos"];
[relation addObject:pic];
[user saveInBackground];
//[pic saveInBackground];
NSString * storyboardName = @"Main";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
UIViewController *myViewController = [storyboard instantiateViewControllerWithIdentifier:@"MainScreen"];
[self presentViewController:myViewController animated:YES completion:nil];
我知道图片本身正在保存,因为当我让图片保存在后台时,当我单击 Pic 类时,它会显示我拍摄的图片。但是,我的问题是,当我查看 User 类并单击 myPhotos 关系时,该关系中没有对象。为什么我的图像不会添加到关系中?