How to get the other side of the Relationship

I am using parse as a DB for my app. I am creating in the app a on to many relationship between two objects. taken from the Parse docs

// Create the post
PFObject *myPost = [PFObject objectWithClassName:@"Post"];
myPost[@"title"] = @"I'm Hungry";
myPost[@"content"] = @"Where should we go for lunch?";

// Create the comment
PFObject *myComment = [PFObject objectWithClassName:@"Comment"];
myComment[@"content"] = @"Let's do Sushirrito.";

// Add a relation between the Post and Comment
myComment[@"parent"] = myPost;

// This will save both myPost and myComment
[myComment saveInBackground];

After saving the relationship how would i get the myComment object from the myPost object? Thanks


It's not a two-way relation. You won't get the myComment object from the myPost object. You'll get the myComment object from querying the Comments class for comments whose "parent" is set to myPost.

PFQuery *query = [PFQuery queryWithClassName:@"Comment"];
[query whereKey:@"parent" equalTo:myPost];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {

Need Your Help

How to find latitude and longitude in node.js?

node.js express latitude-longitude

I am working on web analytics, we are using node.js in server side, we are sending the data using http request(express framework).

Creating multipe page.tpl for different page groups in Drupal 7

php drupal drupal-theming

the site I'm currently building in Drupal is split into two very different areas, both structured quite differently. My solution is to build two different page.tpl pages. Does anyone know what the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.