0
我是新來分析,並試圖創建一個鏈接用戶到他/她的圖片的PFRelation。這裏是我的代碼:iPhone - 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關係時,沒有對象處於該關係中。爲什麼我的圖像不會添加到關係中?