关键意见的无效类型,期望*意见,但得到了字符串

时间:2015-02-01 22:13:35

标签: ios objective-c parse-platform

所以我有我的应用程序,允许用户发送他们的意见,其他用户可以发表评论

我有两张桌子:OpinionCommentOpinion

我的应用基于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"

有没有人有想法解决它?

0 个答案:

没有答案