project_files/HedgewarsMobile/Classes/HogHatViewController.m
changeset 3971 5c82ee165ed5
parent 3948 24daa33a3114
child 4976 088d40d8aba2
equal deleted inserted replaced
3970:0f6e3219c108 3971:5c82ee165ed5
    31     return rotationManager(interfaceOrientation);
    31     return rotationManager(interfaceOrientation);
    32 }
    32 }
    33 
    33 
    34 #pragma mark -
    34 #pragma mark -
    35 #pragma mark View lifecycle
    35 #pragma mark View lifecycle
    36 - (void)viewDidLoad {
    36 -(void) viewDidLoad {
    37     [super viewDidLoad];
    37     [super viewDidLoad];
    38 
    38 
    39     // load all the hat file names and store them into hatArray
    39     // load all the hat file names and store them into hatArray
    40     NSString *hatsDirectory = HATS_DIRECTORY();
    40     NSString *hatsDirectory = HATS_DIRECTORY();
    41     NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:hatsDirectory error:NULL];
    41     NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:hatsDirectory error:NULL];
    49     [hogSprite release];
    49     [hogSprite release];
    50 
    50 
    51     self.title = NSLocalizedString(@"Change hedgehog's hat",@"");
    51     self.title = NSLocalizedString(@"Change hedgehog's hat",@"");
    52 }
    52 }
    53 
    53 
    54 - (void)viewWillAppear:(BOOL)animated {
    54 -(void) viewWillAppear:(BOOL)animated {
    55     [super viewWillAppear:animated];
    55     [super viewWillAppear:animated];
    56 
    56 
    57     // this updates the hog name and its hat
    57     // this updates the hog name and its hat
    58     [self.tableView reloadData];
    58     [self.tableView reloadData];
    59     // this moves the tableview to the top
    59     // this moves the tableview to the top
    70 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    70 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    71     return [self.hatArray count];
    71     return [self.hatArray count];
    72 }
    72 }
    73 
    73 
    74 // Customize the appearance of table view cells.
    74 // Customize the appearance of table view cells.
    75 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    75 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    76 
    76 
    77     static NSString *CellIdentifier = @"Cell";
    77     static NSString *CellIdentifier = @"Cell";
    78 
    78 
    79     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    79     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    80     if (cell == nil)
    80     if (cell == nil)
   101 }
   101 }
   102 
   102 
   103 
   103 
   104 #pragma mark -
   104 #pragma mark -
   105 #pragma mark Table view delegate
   105 #pragma mark Table view delegate
   106 - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   106 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   107     int newRow = [indexPath row];
   107     int newRow = [indexPath row];
   108     int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
   108     int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
   109 
   109 
   110     if (newRow != oldRow) {
   110     if (newRow != oldRow) {
   111         // if the two selected rows differ update data on the hog dictionary and reload table content
   111         // if the two selected rows differ update data on the hog dictionary and reload table content
   132 }
   132 }
   133 
   133 
   134 
   134 
   135 #pragma mark -
   135 #pragma mark -
   136 #pragma mark Memory management
   136 #pragma mark Memory management
   137 - (void)didReceiveMemoryWarning {
   137 -(void) didReceiveMemoryWarning {
   138     // Releases the view if it doesn't have a superview.
   138     self.lastIndexPath = nil;
       
   139     MSG_MEMCLEAN();
   139     [super didReceiveMemoryWarning];
   140     [super didReceiveMemoryWarning];
   140     // Relinquish ownership any cached data, images, etc that aren't in use.
       
   141 }
   141 }
   142 
   142 
   143 - (void)viewDidUnload {
   143 -(void) viewDidUnload {
   144     self.lastIndexPath = nil;
   144     self.lastIndexPath = nil;
   145     self.normalHogSprite = nil;
   145     self.normalHogSprite = nil;
   146     self.teamDictionary = nil;
   146     self.teamDictionary = nil;
   147     self.hatArray = nil;
   147     self.hatArray = nil;
   148     MSG_DIDUNLOAD();
   148     MSG_DIDUNLOAD();
   149     [super viewDidUnload];
   149     [super viewDidUnload];
   150 }
   150 }
   151 
   151 
   152 - (void)dealloc {
   152 -(void) dealloc {
   153     [hatArray release];
   153     [hatArray release];
   154     [teamDictionary release];
   154     [teamDictionary release];
   155     [normalHogSprite release];
   155     [normalHogSprite release];
   156     [lastIndexPath release];
   156     [lastIndexPath release];
   157     [super dealloc];
   157     [super dealloc];