对于我的应用程序,我希望上传的图像有2个父对象,因为根据我自己的理解,这是接近它的最佳方式之一 - 但如果我错了,请纠正我。以下是我正在尝试的代码。
// Create a PFObject around a PFFile and associate it with the current user
PFObject *userPhoto = [PFObject objectWithClassName:@"UserPhoto"];
[userPhoto setObject:imageFile forKey:@"imageFile"];
PFUser *user = [PFUser currentUser];
[userPhoto setObject:user forKey:@"user"];
// Create PFObject and associate userPhoto with Listings as well
PFObject *listings = [PFObject objectWithClassName:@"Listings"];
userPhoto[@"parent"] = listings;
[userPhoto saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
[self refresh:nil];
}
else{
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
它似乎不起作用。任何见解都会有所帮助