简体   繁体   中英

Pointer to blog posts does not contain the replies that belong to the post (Parse, Swift, iOS)

I am working on a social iPhone app using Swift (with a Storyboard) and Parse where users can create posts and reply/comment on posts.

I am trying to create a relationship between a post and the comments that belong to it (ie: A one-to-many relationship where a post (parent) has one or more comments (child)).

This is the structure of the Parse data browser.

Post table: 在此处输入图片说明

Reply table: 在此处输入图片说明

When a user comments/replies on a post, the Reply table shows which post was commented on (the post's objectId from the Post table is shown in the post column of the Reply table (which is aa pointer to the Post object: post Pointer).

However, the reply column in the Post table (which is a pointer to the Reply table) does not show the replies that belong to the post. It's supposed to populate all the replies (reply objectIds) that were made for a given post but is not showing...Why? I appreciate your help!

Note: When a user types a comment in the textfield and presses "Send", a relationship is created when I set the post that this comment belongs to:

var postObject: PFObject?
...
@IBAction func sendCommentButtonPressed(sender: AnyObject) {
  var myComment = PFObject(className: "Reply")
  ...
  myComment["post"] = postObject
  ...
}

Now, I am not sure how and where to create the relationship to set the comment(s) to the post that is being commented on...

You may want to watch this Parse video. Reply belongs to a Post while Post doesn't have to belong to a reply. Plus, theres a whole bunch of information about the subject available

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM