cocoaTouch/SingleTeamViewController.m
author sheepluva
Wed, 07 Apr 2010 16:03:21 +0000
changeset 3322 80afcb97eb46
parent 3316 52f0482b043f
child 3323 091cf214bdd5
permissions -rw-r--r--
* INSTALL file: setting FreePascal to >= 2.2.0 * engine: some more value caching
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
//  SingleTeamViewController.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 "SingleTeamViewController.h"
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    10
#import "HogHatViewController.h"
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 SingleTeamViewController
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    13
@synthesize teamDictionary, hatArray, secondaryItems;
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
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    16
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    17
#pragma mark View lifecycle
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    18
- (void)viewDidLoad {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    19
    [super viewDidLoad];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    20
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    21
    // Uncomment the following line to preserve selection between presentations.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    22
    //self.clearsSelectionOnViewWillAppear = NO;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    23
 
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    24
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    25
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    26
   
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    27
    NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    28
                             NSLocalizedString(@"Color",@""),
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    29
                             NSLocalizedString(@"Grave",@""),
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    30
                             NSLocalizedString(@"Voice",@""),
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    31
                             NSLocalizedString(@"Fort",@""),
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    32
                             NSLocalizedString(@"Flag",@""),
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    33
                             NSLocalizedString(@"Level",@""),nil];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    34
    self.secondaryItems = array;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    35
    [array release];
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    36
    
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    37
    // load data about the team and extract info
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    38
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    39
    NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/Teams/%@.plist",[paths objectAtIndex:0],self.title];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    40
    NSMutableDictionary *teamDict = [[NSMutableDictionary alloc] initWithContentsOfFile:teamFile];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    41
    [teamFile release];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    42
    self.teamDictionary = teamDict;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    43
    [teamDict release];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    44
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    45
    // listen if any childController modifies the plist and write it if needed
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    46
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setWriteNeeded) name:@"setWriteNeedTeams" object:nil];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    47
    isWriteNeeded = NO;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    48
}
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    49
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    50
- (void)viewWillAppear:(BOOL)animated {
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    51
    [super viewWillAppear:animated];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    52
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    53
    // grab the name of the team
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    54
    self.title = [self.teamDictionary objectForKey:@"teamname"];
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    55
    
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    56
    // load the images of the hat for aach hog
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    57
    NSArray *hogArray = [self.teamDictionary objectForKey:@"hedgehogs"];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    58
    NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:[hogArray count]];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    59
    for (NSDictionary *hog in hogArray) {
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    60
        NSString *hatFile = [[NSString alloc] initWithFormat:@"%@/Data/Graphics/Hats/%@.png",[[NSBundle mainBundle] resourcePath],[hog objectForKey:@"hat"]];
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    61
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    62
        UIImage *image = [[UIImage alloc] initWithContentsOfFile: hatFile];
3316
52f0482b043f fix a couple of leaks in hte ifrontend
koda
parents: 3315
diff changeset
    63
        [hatFile release];
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    64
        CGRect firstSpriteArea = CGRectMake(0, 0, 32, 32);
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    65
        CGImageRef cgImgage = CGImageCreateWithImageInRect([image CGImage], firstSpriteArea);
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    66
        [image release];
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    67
        
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    68
        UIImage *hatSprite = [[UIImage alloc] initWithCGImage:cgImgage];
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    69
        [array addObject:hatSprite];
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    70
        CGImageRelease(cgImgage);
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    71
        [hatSprite release];
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    72
    }
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    73
    self.hatArray = array;
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    74
    [array release];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    75
    
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    76
    [self.tableView reloadData];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    77
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    78
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
- (void)viewDidAppear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    81
    [super viewDidAppear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    82
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    83
*/
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    84
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    85
-(void) setWriteNeeded {
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    86
    isWriteNeeded = YES;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    87
}
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    88
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    89
// write to disk the team dictionary
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    90
-(void) viewWillDisappear:(BOOL)animated {
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    91
    [super viewWillDisappear:animated];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    92
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    93
    if (isWriteNeeded) {
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    94
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    95
        NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/Teams/%@.plist",[paths objectAtIndex:0],self.title];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    96
        [self.teamDictionary writeToFile: teamFile atomically:YES];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    97
        [teamFile release];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    98
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    99
        isWriteNeeded = NO;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   100
    }
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   101
}
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   102
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   103
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   104
- (void)viewDidDisappear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   105
    [super viewDidDisappear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   106
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   107
*/
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   108
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   109
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   110
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   111
}
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
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   114
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   115
#pragma mark Table view data source
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   116
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   117
    return 3;
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
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
   121
    NSInteger rows = 0;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   122
    switch (section) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   123
        case 0:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   124
            rows = 1;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   125
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   126
        case 1:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   127
            rows = 8;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   128
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   129
        case 2:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   130
            rows = 6;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   131
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   132
        default:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   133
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   134
    }
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   135
    return rows;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   136
}
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
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   139
    static NSString *CellIdentifier = @"Cell";
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
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   142
    if (cell == nil) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   143
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   144
                                       reuseIdentifier:CellIdentifier] autorelease];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   145
    }
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   146
    NSArray *hogArray;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   147
    NSInteger row = [indexPath row];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   148
    switch ([indexPath section]) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   149
        case 0:
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   150
            cell.textLabel.text = self.title;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   151
            cell.imageView.image = nil;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   152
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   153
        case 1:
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   154
            hogArray = [self.teamDictionary objectForKey:@"hedgehogs"];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   155
            cell.textLabel.text = [[hogArray objectAtIndex:row] objectForKey:@"hogname"];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   156
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   157
            cell.imageView.image = [self.hatArray objectAtIndex:row];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   158
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   159
        case 2:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   160
            cell.textLabel.text = [self.secondaryItems objectAtIndex:row];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   161
            cell.imageView.image = nil;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   162
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   163
        default:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   164
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   165
    }
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   166
    
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   167
    return cell;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   168
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   169
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   170
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   171
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   172
// Override to support conditional editing of the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   173
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   174
    // 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
   175
    return YES;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   176
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   177
*/
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   178
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   179
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   180
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   181
// Override to support editing the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   182
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   183
    
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   184
    if (editingStyle == UITableViewCellEditingStyleDelete) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   185
        // Delete the row from the data source
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   186
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
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
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   189
        // 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
   190
    }   
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   191
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   192
*/
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   193
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   194
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   195
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   196
// Override to support rearranging the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   197
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   198
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   199
*/
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   200
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   201
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   202
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   203
// Override to support conditional rearranging of the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   204
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   205
    // 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
   206
    return YES;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   207
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   208
*/
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   209
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   210
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   211
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   212
#pragma mark Table view delegate
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   213
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   214
    if (1 == [indexPath section]) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   215
        if (nil == hogChildController) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   216
            hogChildController = [[HogHatViewController alloc] initWithStyle:UITableViewStyleGrouped];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   217
        }
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   218
        
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   219
        // cache the dictionary file of the team, so that other controllers can modify it
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   220
        hogChildController.teamDictionary = self.teamDictionary;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   221
        hogChildController.selectedHog = [indexPath row];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   222
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   223
        [self.navigationController pushViewController:hogChildController animated:YES];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   224
    }
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   225
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   226
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   227
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   228
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   229
#pragma mark Memory management
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   230
-(void) didReceiveMemoryWarning {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   231
    // Releases the view if it doesn't have a superview.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   232
    [super didReceiveMemoryWarning];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   233
    // Relinquish ownership any cached data, images, etc that aren't in use.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   234
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   235
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   236
-(void) viewDidUnload {
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   237
    self.hatArray = nil;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   238
    self.secondaryItems = nil;
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   239
    self.teamDictionary = nil;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   240
    [super viewDidUnload];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   241
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   242
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   243
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   244
-(void) dealloc {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   245
    [secondaryItems release];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   246
    [hatArray release];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   247
    [teamDictionary release];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   248
    [super dealloc];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   249
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   250
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   251
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   252
@end
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   253