Sorry if this is an extremely simple and dumb question. I'm still really new to Parse.
Suppose I have a Schedule object, and a Schedule object can have a few ScheduleItem objects (not many). I decided to model this using arrays for relations, such as:
PFObject *first = ...
PFObject *second = ...
PFObject *third = ...
PFObject *schedule = [PFObject objectWithClassName:@Schedule"];
schedule[@"scheduleItems"] = @[first, second, third];
Suppose I want to later query for these ScheduleItems which belong to this schedule AND use it in a PFQueryTableViewController. I can't just query for this schedule and access its items through the array because PFQueryTableViewController uses the results of the PFQuery as the data source for the table view. And I'm not sure how to query for "the ScheduleItem objects that live in the array 'scheduleItems' on a particular Schedule object". I see the query method whereKey:containedIn:
, but it doesn't quite seem to match, because I don't have a reference to this array before I do the query. It does seem like I need to do some sort of nested/compound query because for part of this query, I need to query for the Schedule object, but I'm not sure exactly how this works.
EDIT: To clarify this question. Suppose the Schedule object has a name "Today". I know I can construct a query for that Schedule object and tell it to include the "scheduleItems" field:
PFQuery *query = [PFQuery queryWithClassName:@"Schedule"];
[query whereKey:@"name" equalTo:@"Today"]; // or query by its objectId
[query includeKey:@"scheduleItems"];
I know that if I execute this query with something like findObjectsInBackgroundWithBlock:
, the direct query result is an array of one object, the Schedule object, with all of the ScheduleItems available through the scheduleItems field.
My problem is, I don't want to execute this query myself - I want to use those ScheduleItems as the cells in a PFQueryTableViewController, which assumes a one-to-one mapping between cells and the direct query result objects. If I use the above query with the PFQueryTableViewController, the direct query result is an array of one object, meaning the table only has one object. In short, I don't know how to tell PFQueryTableViewController to do a query, but then use its related array of objects to populate the table.