cocoaTouch/HogHatViewController.m
author koda
Tue, 06 Apr 2010 21:54:46 +0000
changeset 3315 4e2813713358
parent 3312 6d8f1c76756d
child 3316 52f0482b043f
permissions -rw-r--r--
usa a cached dictionary and write only when needed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     1
//
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     2
//  HogHatViewController.m
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     3
//  HedgewarsMobile
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     4
//
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     5
//  Created by Vittorio on 02/04/10.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     7
//
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     8
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     9
#import "HogHatViewController.h"
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    10
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    11
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    12
@implementation HogHatViewController
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    13
@synthesize teamDictionary, hatArray, hatSprites, lastIndexPath, selectedHog;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    14
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    15
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    16
#pragma mark View lifecycle
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    17
- (void)viewDidLoad {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    18
    [super viewDidLoad];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    19
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    20
    // load all the hat file names and store them into hatArray
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    21
    NSString *hatPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Graphics/Hats/"];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    22
    NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:hatPath error:NULL];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    23
    self.hatArray = array;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    24
    
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    25
    // load all the hat images from the previous array but save only the first sprite and store it in hatSprites
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    26
    NSMutableArray *spriteArray = [[NSMutableArray alloc] initWithCapacity:[hatArray count]];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    27
    for (int i=0; i< [hatArray count]; i++) {
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    28
        NSString *hatFile = [hatPath stringByAppendingString:[hatArray objectAtIndex:i]];
3308
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
    29
        
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
    30
        UIImage *image = [[UIImage alloc] initWithContentsOfFile: hatFile];
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
    31
        CGRect firstSpriteArea = CGRectMake(0, 0, 32, 32);
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
    32
        CGImageRef cgImgage = CGImageCreateWithImageInRect([image CGImage], firstSpriteArea);
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
    33
        [image release];
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
    34
        
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
    35
        UIImage *hatSprite = [[UIImage alloc] initWithCGImage:cgImgage];
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
    36
        [spriteArray addObject:hatSprite];
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
    37
        CGImageRelease(cgImgage);
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
    38
        [hatSprite release];
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
    39
    }
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
    40
    self.hatSprites = spriteArray;
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
    41
    [spriteArray release];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    42
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    43
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    44
- (void)viewWillAppear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    45
    [super viewWillAppear:animated];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    46
    self.title = [[[teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:selectedHog] objectForKey:@"hogname"];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    47
3308
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
    48
    // this updates the hog name and its hat
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    49
    [self.tableView reloadData];
3308
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
    50
    // this moves the tableview to the top
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    51
    [self.tableView setContentOffset:CGPointMake(0,0) animated:NO];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    52
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    53
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    54
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    55
- (void)viewDidAppear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    56
    [super viewDidAppear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    57
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    58
*/
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    59
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    60
- (void)viewWillDisappear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    61
    [super viewWillDisappear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    62
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    63
*/
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    64
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    65
- (void)viewDidDisappear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    66
    [super viewDidDisappear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    67
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    68
*/
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    69
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    70
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    71
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    72
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    73
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    74
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    75
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    76
#pragma mark Table view data source
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    77
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    78
    return 2;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    79
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    80
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    81
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    82
    NSInteger rows;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    83
    if (0 == section) 
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    84
        rows = 1;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    85
    else
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    86
        rows = [self.hatArray count];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    87
    return rows;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    88
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    89
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    90
// Customize the appearance of table view cells.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    91
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    92
    
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    93
    static NSString *CellIdentifier = @"Cell";
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    94
    
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    95
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    96
    if (cell == nil) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    97
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    98
    }
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    99
    
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   100
    NSDictionary *hog = [[teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:selectedHog];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   101
    if (0 == [indexPath section]) {
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   102
        cell.textLabel.text = self.title;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   103
        cell.imageView.image = nil;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   104
        cell.accessoryType = UITableViewCellAccessoryNone;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   105
    } else {
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   106
        cell.textLabel.text = [[hatArray objectAtIndex:[indexPath row]] stringByDeletingPathExtension];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   107
        if ([cell.textLabel.text isEqualToString:[hog objectForKey:@"hat"]]) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   108
            cell.accessoryType = UITableViewCellAccessoryCheckmark;
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   109
            self.lastIndexPath = indexPath;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   110
        } else {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   111
            cell.accessoryType = UITableViewCellAccessoryNone;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   112
        }
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   113
        
3308
b6dcae4b6d2c make the tables work also on iphone
koda
parents: 3305
diff changeset
   114
        cell.imageView.image = [hatSprites objectAtIndex:[indexPath row]];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   115
    }
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   116
    
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   117
    return cell;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   118
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   119
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   120
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   121
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   122
// Override to support conditional editing of the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   123
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   124
    // Return NO if you do not want the specified item to be editable.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   125
    return YES;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   126
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   127
*/
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   128
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   129
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   130
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   131
// Override to support editing the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   132
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   133
    
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   134
    if (editingStyle == UITableViewCellEditingStyleDelete) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   135
        // Delete the row from the data source
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   136
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   137
    }   
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   138
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   139
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   140
    }   
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   141
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   142
*/
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   143
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   144
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   145
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   146
// Override to support rearranging the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   147
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   148
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   149
*/
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   150
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   151
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   152
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   153
// Override to support conditional rearranging of the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   154
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   155
    // Return NO if you do not want the item to be re-orderable.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   156
    return YES;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   157
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   158
*/
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   159
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   160
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   161
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   162
#pragma mark Table view delegate
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   163
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   164
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   165
    if (1 == [indexPath section]) {
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   166
        int newRow = [indexPath row];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   167
        int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   168
        
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   169
        if (newRow != oldRow) {
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   170
            // if the two selected rows differ update data on the hog dictionary and reload table content
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   171
            NSDictionary *oldHog = [[teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:selectedHog];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   172
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   173
            NSMutableDictionary *newHog = [[NSMutableDictionary alloc] initWithDictionary: oldHog];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   174
            [newHog setObject:[[hatArray objectAtIndex:newRow] stringByDeletingPathExtension] forKey:@"hat"];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   175
            [[teamDictionary objectForKey:@"hedgehogs"] replaceObjectAtIndex:selectedHog withObject:newHog];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   176
            [newHog release];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   177
            
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   178
            // tell our boss to write this new stuff on disk
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   179
            [[NSNotificationCenter defaultCenter] postNotificationName:@"setWriteNeedTeams" object:nil];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   180
            [self.tableView reloadData];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   181
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   182
            self.lastIndexPath = indexPath;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   183
            [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   184
        } 
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   185
        [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   186
    }
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   187
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   188
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   189
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   190
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   191
#pragma mark Memory management
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   192
- (void)didReceiveMemoryWarning {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   193
    // Releases the view if it doesn't have a superview.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   194
    [super didReceiveMemoryWarning];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   195
    // Relinquish ownership any cached data, images, etc that aren't in use.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   196
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   197
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   198
- (void)viewDidUnload {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   199
    [super viewDidUnload];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   200
    self.lastIndexPath = nil;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   201
    self.hatSprites = nil;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   202
    self.teamDictionary = nil;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   203
    self.hatArray = nil;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   204
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   205
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   206
- (void)dealloc {
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   207
    [hatArray release];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   208
    [teamDictionary release];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   209
    [hatSprites release];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   210
    [lastIndexPath release];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   211
    [super dealloc];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   212
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   213
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   214
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   215
@end
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   216