问题
CoreData and ResultsController make the job really easy. But...
Here is the situation:
I have a functional resultsController in one tableView. When selecting a row, I go to another tableView that will show the child entity. With coreData, the child entity is ready to use. But how do I start another resultsController with this child entity? Do I need to fetchRequest again for this new resultsController using predicate to filter?
Parent TablewView: Select row on resultsController -> Child TableView: init from entity received and init another resultsController -> Desc of Child TableView: show detail from the row selected on the second RC.
Is there a better way?
回答1:
If your second UITableView is just presenting the detail of 1 NSManagedObject, why create a resultsController. Pass a pointer to the NSManagedObject to the new TableView and handle it's displaying in the UITableViewDataSource protocol method.
You may want to order the element you want for each row in a NSArray, for shorter - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath implementation.
The NSArray must be done before the TableView first try to display itself.
来源:https://stackoverflow.com/questions/8736692/resultscontroller-to-another-resultscontroller