Just create another UITableViewController
subclass, wrap it into navigation controller and push. Make sure to use NSFetchedResultsController
to populate your table views. You should pass Game object to second table view controller in order to build predicate for it.
Some code snippets:
Wrapping view controller into navigation in table view controller's tableView:(UITableView *)tableView didSelectRowAtIndexPath:
method.
TagsViewController *tagsViewController = [[TagsViewController alloc] initWithMode:TagsViewControllerModeSelect]; // You can view plain style, I've just created my initializer
tagsViewController.unit = self.unit; // You can pass the Game here
[self.navigationController pushViewController:tagsViewController animated:YES];
[tagsViewController release];
Here is fetched results controller lazy initializer
- (NSFetchedResultsController*)fetchedResultsController
{
if(fetchedResultsController != nil)
return fetchedResultsController;
NSEntityDescription* entity = [NSEntityDescription entityForName:@"StudyUnit" inManagedObjectContext:managedObjectContext];
NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:entity];
NSString *predicateString = [[DefaultsManager sharedInstance] filterMode] == kFilterModeShowAll ? @"explanation != '' AND show == YES" : @"ANY tag.show == YES AND explanation != '' AND show == YES";
NSPredicate *predicate = [NSPredicate predicateWithFormat:predicateString]; // Here goes your predicate to query players for particular game
[fetchRequest setPredicate:predicate];
NSSortDescriptor* sortByWordDescriptor = [[NSSortDescriptor alloc] initWithKey:@"subject" ascending:YES];
NSArray* sortArray = [[NSArray alloc] initWithObjects:sortByWordDescriptor, nil];
[fetchRequest setSortDescriptors:sortArray];
NSFetchedResultsController* controller = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:nil cacheName:@"Hmm"];
controller.delegate = self;
self.fetchedResultsController = controller;
[fetchRequest release];
[sortByWordDescriptor release];
[sortArray release];
[controller release];
return fetchedResultsController;
}
Then just implement NSFetchedResultsController
delegates, send performFetch
message and voila!
UPD:
Assuming your game object is generally NSManagedObject
declared in the second controller:
NSManagedObject *game;
Then you can build predicate something like this:
NSEntityDescription* entity = [NSEntityDescription entityForName:@"Player" inManagedObjectContext:managedObjectContext];
//...
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"game == %@", self.game];
This is just theoretically, can't test it sorry ^^