project_files/HedgewarsMobile/Classes/TeamSettingsViewController.m
branchios-revival
changeset 11217 e68b3e392091
parent 10108 c68cf030eded
child 11229 b49dfdf628f6
equal deleted inserted replaced
11216:76fd61a88c1e 11217:e68b3e392091
   134 }
   134 }
   135 
   135 
   136 
   136 
   137 #pragma mark -
   137 #pragma mark -
   138 #pragma mark Table view delegate
   138 #pragma mark Table view delegate
   139 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   139 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
   140     if (childController == nil) {
   140 {
   141         childController = [[SingleTeamViewController alloc] initWithStyle:UITableViewStyleGrouped];
   141     SingleTeamViewController *singleTeamViewController = [[SingleTeamViewController alloc] initWithStyle:UITableViewStyleGrouped];
   142     }
   142     
   143 
       
   144     NSInteger row = [indexPath row];
   143     NSInteger row = [indexPath row];
   145     NSString *selectedTeamFile = [listOfTeams objectAtIndex:row];
   144     NSString *selectedTeamFile = [listOfTeams objectAtIndex:row];
   146 
   145 
   147     // this must be set so childController can load the correct plist
   146     // this must be set so childController can load the correct plist
   148     childController.teamName = [selectedTeamFile stringByDeletingPathExtension];
   147     singleTeamViewController.teamName = [selectedTeamFile stringByDeletingPathExtension];
   149     [childController.tableView setContentOffset:CGPointMake(0,0) animated:NO];
   148     [singleTeamViewController.tableView setContentOffset:CGPointMake(0,0) animated:NO];
   150 
   149 
   151     [self.navigationController pushViewController:childController animated:YES];
   150     [self.navigationController pushViewController:singleTeamViewController animated:YES];
       
   151     [singleTeamViewController release];
       
   152     
   152     [tableView deselectRowAtIndexPath:indexPath animated:YES];
   153     [tableView deselectRowAtIndexPath:indexPath animated:YES];
   153 }
   154 }
   154 
   155 
   155 
   156 
   156 #pragma mark -
   157 #pragma mark -
   157 #pragma mark Memory management
   158 #pragma mark Memory management
   158 -(void) didReceiveMemoryWarning {
   159 -(void) didReceiveMemoryWarning
       
   160 {
   159     // Releases the view if it doesn't have a superview.
   161     // Releases the view if it doesn't have a superview.
   160     [super didReceiveMemoryWarning];
   162     [super didReceiveMemoryWarning];
   161     // Relinquish ownership any cached data, images, etc that aren't in use.
   163     // Relinquish ownership any cached data, images, etc that aren't in use.
   162     if (childController.view.superview == nil )
       
   163         childController = nil;
       
   164 }
   164 }
   165 
   165 
   166 -(void) viewDidUnload {
   166 -(void) viewDidUnload
       
   167 {
   167     self.listOfTeams = nil;
   168     self.listOfTeams = nil;
   168     childController = nil;
       
   169     MSG_DIDUNLOAD();
   169     MSG_DIDUNLOAD();
   170     [super viewDidUnload];
   170     [super viewDidUnload];
   171 }
   171 }
   172 
   172 
   173 -(void) dealloc {
   173 -(void) dealloc
       
   174 {
   174     releaseAndNil(listOfTeams);
   175     releaseAndNil(listOfTeams);
   175     releaseAndNil(childController);
       
   176     [super dealloc];
   176     [super dealloc];
   177 }
   177 }
   178 
   178 
   179 
   179 
   180 @end
   180 @end