// // ActorsTableViewController.m // TFBrowser // // Created by JB Meyer on 1/9/10. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import "ActorsTableViewController.h" #import "Actor.h" #import "TFObjects.h" #import "ActorsDetailsTableViewController.h" #import "ActorDataSource.h" #import "TFBrowserAppDelegate.h" @implementation ActorsTableViewController @synthesize actorsTableView ; @synthesize actorDataSource, actorsDetailsTableViewController ; /* - (ActorsTableViewController *)init { if ([super initWithNibName:@"ActorsTableViewController" bundle:nil]) { // retain the data source ActorDataSource * theDataSource = [[ActorDataSource alloc]init]; // actorDataSource = theDataSource ; self.tableView.dataSource = actorDataSource; // set the title, and tab bar images from the dataSource // object. These are part of the ElementsDataSource Protocol self.title = [actorDataSource name]; self.tabBarItem.image = [actorDataSource tabBarImage]; // set the long name shown in the navigation bar self.navigationItem.title=[actorDataSource navigationBarName]; // create a custom navigation bar button and set it to always say "back" UIBarButtonItem *temporaryBarButtonItem=[[UIBarButtonItem alloc] init]; temporaryBarButtonItem.title=@"Back"; self.navigationItem.backBarButtonItem = temporaryBarButtonItem; [theDataSource release]; [temporaryBarButtonItem release]; } return self; } */ - (void)viewDidLoad { [super viewDidLoad]; if ( actorDataSource == nil ) { actorDataSource = [[ActorDataSource alloc]init]; self.tableView.dataSource = actorDataSource ; } // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } #pragma mark Table view methods - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; Actor * actor = (Actor *)[self.actorDataSource tfObjectForIndexPath:indexPath] ; if ( actor != nil ) { ActorsDetailsTableViewController * myActorViewController = [[ActorsDetailsTableViewController alloc] initWithNibName:@"ActorsDetailsTableViewController" bundle:nil ] ; [self setActorsDetailsTableViewController:myActorViewController]; actorsDetailsTableViewController.hidesBottomBarWhenPushed = YES ; [myActorViewController release ]; actorsDetailsTableViewController.actor = actor ; // push the element view controller onto the navigation stack to display it TFBrowserAppDelegate * delegate = [[UIApplication sharedApplication] delegate]; [[delegate actorsNavigationController] pushViewController:actorsDetailsTableViewController animated:YES ]; [ actor release]; } } - (void)dealloc { [actorDataSource release]; [actorsDetailsTableViewController release]; [super dealloc]; } @end