objective c - How to do a PFRelation or relational database query with parse in IOS -
how can perform pfrelation query when select shop displays menu item associated it.
my tables in parse looks
menu table/class
retailer table/class
in ios code have 2 uitableviews 1) uitableview display "shop_name" retailer table, 2) uitableview display "item_name" menu table.
i have gone far displaying "item_name" irrespective of association/relation table. code looks this.
- (void) retrievefromparse{ pfquery *retrievemenu = [pfquery querywithclassname:@"menu"]; //[retrievemenu wherekey:@"retailer_id" equalto:_shopobjectid]; //test [retrievemenu findobjectsinbackgroundwithblock:^(nsarray *menuobjects, nserror *error) { if(!error){ _menuobjects = [[nsmutablearray alloc]initwitharray:menuobjects]; nslog(@"%@", _menuobjects); } [_menuobjectstableview reloaddata]; }]; }
i have logic pass "objectid" of current selectedrow in uitableview1. hoping use "objectid" perform relational queries "item_name" related shop displayed in uitableview2, i'm not sure how that.
if understanding correctly, each menu object in more 1 shop, correct? if so, how want structure query:
pfquery *query = [pfquery querywithclassname:@"menu"]; [query wherekey:@"retailer_id" equalto:[pfobject objectwithoutdatawithclassname:@"retailer_location_class" objectid:@"id passed controller"]];
this query menu class items contain selected retailer in "retailer_id" field.
Comments
Post a Comment