所以我有我的应用程序,允许用户发送他们的意见,其他用户可以发表评论
我有两张桌子:Opinion
和CommentOpinion
我的应用基于Master/Detail
模板:
OpinionTimelineTableViewController
显示用户发布的所有意见
OpinionCommentTableViewController
显示所选意见内容以及所选意见的所有评论
所以,我通过ViewControllers
方法成功传递了prepareForSegue
之间所需的数据,一切正常:
在OpinionTimelineTableViewController.m
:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"OpinionComSegue"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
OpinionCommentTableViewController *oPTvc = segue.destinationViewController;
// self.tempObj is a PFObject declared as a property in the .h file (it works)
// self.opinionObjects is an Array declared as a property in the .h file who contains the data I need
self.tempObj = [self.opinionObjects objectAtIndex:indexPath.row];
NSString *opinionContent = [self.tempObj objectForKey:@"content"];
NSString *opinionId = [self.tempObj objectId];
NSDateFormatter *dateForm = [[NSDateFormatter alloc] init];
dateForm.dateFormat = @"dd-MM-yyyy à HH:mm";
NSString *opinionDate = [dateForm stringFromDate:self.tempObj.createdAt];
// "sel" for "selected"
oPTvc.contentSelOpinion = opinionContent;
oPTvc.dateSelOpinion = opinionDate;
oPTvc.selOpinionId = opinionId;
}
}
现在,在OpinionCommentTableViewController.m
:
- (IBAction)sendComment:(id)sender {
PFObject *opinionCom = [PFObject objectWithClassName:@"CommentOpinion"];
opinionCom[@"content"] = self.texteCommToolBar.text;
opinionCom[@"userId"] = [PFUser currentUser];
opinionCom[@"opinionId"] = self.selOpinionId;
[opinionCom saveInBackground];
}
已成功检索所选意见的objectId
,但当我使用模拟器并尝试发布评论时,Parse云中没有任何内容存储,我有一个漂亮的错误行:"invalid type for key opinionId, expected *Opinion, but got string"
有没有人有想法解决它?