project_files/HedgewarsMobile/Classes/WeaponSettingsViewController.m
branchios-revival
changeset 11217 e68b3e392091
parent 10108 c68cf030eded
child 11229 b49dfdf628f6
equal deleted inserted replaced
11216:76fd61a88c1e 11217:e68b3e392091
   129     [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
   129     [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
   130 }
   130 }
   131 
   131 
   132 #pragma mark -
   132 #pragma mark -
   133 #pragma mark Table view delegate
   133 #pragma mark Table view delegate
   134 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   134 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
   135     if (childController == nil) {
   135 {
   136         childController = [[SingleWeaponViewController alloc] initWithStyle:UITableViewStyleGrouped];
   136     SingleWeaponViewController *singleWeaponViewController = [[SingleWeaponViewController alloc] initWithStyle:UITableViewStyleGrouped];
   137     }
       
   138 
   137 
   139     NSInteger row = [indexPath row];
   138     NSInteger row = [indexPath row];
   140     NSString *selectedWeaponFile = [self.listOfWeapons objectAtIndex:row];
   139     NSString *selectedWeaponFile = [self.listOfWeapons objectAtIndex:row];
   141 
   140 
   142     // this must be set so childController can load the correct plist
   141     // this must be set so childController can load the correct plist
   143     childController.weaponName = [selectedWeaponFile stringByDeletingPathExtension];
   142     singleWeaponViewController.weaponName = [selectedWeaponFile stringByDeletingPathExtension];
   144     [childController.tableView setContentOffset:CGPointMake(0,0) animated:NO];
   143     [singleWeaponViewController.tableView setContentOffset:CGPointMake(0,0) animated:NO];
   145 
   144 
   146     [self.navigationController pushViewController:childController animated:YES];
   145     [self.navigationController pushViewController:singleWeaponViewController animated:YES];
       
   146     [singleWeaponViewController release];
       
   147     
   147     [tableView deselectRowAtIndexPath:indexPath animated:YES];
   148     [tableView deselectRowAtIndexPath:indexPath animated:YES];
   148 }
   149 }
   149 
   150 
   150 
   151 
   151 #pragma mark -
   152 #pragma mark -
   152 #pragma mark Memory management
   153 #pragma mark Memory management
   153 -(void)didReceiveMemoryWarning {
   154 -(void)didReceiveMemoryWarning
       
   155 {
   154     [super didReceiveMemoryWarning];
   156     [super didReceiveMemoryWarning];
   155     if (childController.view.superview == nil )
       
   156         childController = nil;
       
   157 }
   157 }
   158 
   158 
   159 -(void) viewDidUnload {
   159 -(void) viewDidUnload
       
   160 {
   160     self.listOfWeapons = nil;
   161     self.listOfWeapons = nil;
   161     childController = nil;
       
   162     MSG_DIDUNLOAD();
   162     MSG_DIDUNLOAD();
   163     [super viewDidUnload];
   163     [super viewDidUnload];
   164 }
   164 }
   165 
   165 
   166 
   166 
   167 -(void) dealloc {
   167 -(void) dealloc
       
   168 {
   168     releaseAndNil(listOfWeapons);
   169     releaseAndNil(listOfWeapons);
   169     releaseAndNil(childController);
       
   170     [super dealloc];
   170     [super dealloc];
   171 }
   171 }
   172 
   172 
   173 
   173 
   174 @end
   174 @end