Skip to content

Instantly share code, notes, and snippets.

@Jmayhak
Created August 25, 2012 23:08
Show Gist options
  • Save Jmayhak/3472015 to your computer and use it in GitHub Desktop.
Save Jmayhak/3472015 to your computer and use it in GitHub Desktop.
create pfobject relation
PFObject *myPost = [PFObject objectWithClassName:@"Post"];
[myPost setObject:@"I'm Hungry" forKey:@"title"];
[myPost setObject:@"Where should we go for lunch?" forKey:@"content"];
// Create the comment
PFObject *myComment = [PFObject objectWithClassName:@"Comment"];
[myComment setObject:@"Let's do Sushirrito." forKey:@"content"];
// Add a relation between the Post and Comment
[myComment setObject:myPost forKey:@"parent"];
// This will save both myPost and myComment
[myComment saveInBackground];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment