20. Relation -one-to-many-
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];
12年7月23日月曜日
21. Relation -one-to-many-
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];
12年7月23日月曜日
23. Relation -many-to-many-
Parse blog : A More Scalable Many-to-Many Approach
PFObject *post2 = [PFObject objectWithClassName:@"Post"];
[post2 setObject:@"I'm Hungry" forKey:@"title"];
[post2 setObject:@"Where should we go for dinner?" forKey:@"content"];
PFRelation *relation = [post2 relationforKey:@"likes"];
for (PFObject *object in objects){
[relation addObject: object];
}
[post2 save];
12年7月23日月曜日
24. Relation -many-to-many-
Parse blog : A More Scalable Many-to-Many Approach
PFObject *post2 = [PFObject objectWithClassName:@"Post"];
[post2 setObject:@"I'm Hungry" forKey:@"title"];
[post2 setObject:@"Where should we go for dinner?" forKey:@"content"];
PFRelation *relation = [post2 relationforKey:@"likes"];
for (PFObject *object in objects){
[relation addObject: object];
}
[post2 save];
12年7月23日月曜日
25. Relation -many-to-many-
Parse blog : A More Scalable Many-to-Many Approach
PFObject *post2 = [PFObject objectWithClassName:@"Post"];
[post2 setObject:@"I'm Hungry" forKey:@"title"];
[post2 setObject:@"Where should we go for dinner?" forKey:@"content"];
PFRelation *relation = [post2 relationforKey:@"likes"];
for (PFObject *object in objects){
[relation addObject: object];
}
[post2 save];
12年7月23日月曜日