cocoaTouch/SingleTeamViewController.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
//  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];
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    63
        CGRect firstSpriteArea = CGRectMake(0, 0, 32, 32);
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    64
        CGImageRef cgImgage = CGImageCreateWithImageInRect([image CGImage], firstSpriteArea);
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    65
        [image release];
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    66
        
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    67
        UIImage *hatSprite = [[UIImage alloc] initWithCGImage:cgImgage];
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    68
        [array addObject:hatSprite];
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    69
        CGImageRelease(cgImgage);
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    70
        [hatSprite release];
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    71
    }
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    72
    self.hatArray = array;
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    73
    [array release];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    74
    
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    75
    [self.tableView reloadData];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    76
}
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
- (void)viewDidAppear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    80
    [super viewDidAppear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    81
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    82
*/
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    83
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    84
-(void) setWriteNeeded {
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    85
    isWriteNeeded = YES;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    86
}
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
// write to disk the team dictionary
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    89
-(void) viewWillDisappear:(BOOL)animated {
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    90
    [super viewWillDisappear:animated];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    91
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    92
    if (isWriteNeeded) {
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    93
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    94
        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
    95
        [self.teamDictionary writeToFile: teamFile atomically:YES];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    96
        [teamFile release];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    97
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    98
        isWriteNeeded = NO;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    99
    }
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   100
}
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   101
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   102
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   103
- (void)viewDidDisappear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   104
    [super viewDidDisappear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   105
}
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
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   109
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   110
}
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
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   114
#pragma mark Table view data source
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   115
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   116
    return 3;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   117
}
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
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
   120
    NSInteger rows = 0;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   121
    switch (section) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   122
        case 0:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   123
            rows = 1;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   124
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   125
        case 1:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   126
            rows = 8;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   127
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   128
        case 2:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   129
            rows = 6;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   130
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   131
        default:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   132
            break;
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
    return rows;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   135
}
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
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   138
    static NSString *CellIdentifier = @"Cell";
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   139
    
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   140
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   141
    if (cell == nil) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   142
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   143
                                       reuseIdentifier:CellIdentifier] autorelease];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   144
    }
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   145
    NSArray *hogArray;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   146
    NSInteger row = [indexPath row];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   147
    switch ([indexPath section]) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   148
        case 0:
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   149
            cell.textLabel.text = self.title;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   150
            cell.imageView.image = nil;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   151
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   152
        case 1:
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   153
            hogArray = [self.teamDictionary objectForKey:@"hedgehogs"];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   154
            cell.textLabel.text = [[hogArray objectAtIndex:row] objectForKey:@"hogname"];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   155
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   156
            cell.imageView.image = [self.hatArray objectAtIndex:row];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   157
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   158
        case 2:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   159
            cell.textLabel.text = [self.secondaryItems objectAtIndex:row];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   160
            cell.imageView.image = nil;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   161
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   162
        default:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   163
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   164
    }
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
    return cell;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   167
}
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
// Override to support conditional editing of the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   172
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   173
    // 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
   174
    return YES;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   175
}
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
// Override to support editing the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   181
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   182
    
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   183
    if (editingStyle == UITableViewCellEditingStyleDelete) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   184
        // Delete the row from the data source
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   185
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   186
    }   
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   187
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   188
        // 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
   189
    }   
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
// Override to support rearranging the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   196
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
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
*/
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
// Override to support conditional rearranging of the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   203
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   204
    // 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
   205
    return YES;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   206
}
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
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   211
#pragma mark Table view delegate
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   212
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   213
    if (1 == [indexPath section]) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   214
        if (nil == hogChildController) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   215
            hogChildController = [[HogHatViewController alloc] initWithStyle:UITableViewStyleGrouped];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   216
        }
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   217
        
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   218
        // 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
   219
        hogChildController.teamDictionary = self.teamDictionary;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   220
        hogChildController.selectedHog = [indexPath row];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   221
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   222
        [self.navigationController pushViewController:hogChildController animated:YES];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   223
    }
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
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   228
#pragma mark Memory management
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   229
-(void) didReceiveMemoryWarning {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   230
    // Releases the view if it doesn't have a superview.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   231
    [super didReceiveMemoryWarning];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   232
    // Relinquish ownership any cached data, images, etc that aren't in use.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   233
}
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
-(void) viewDidUnload {
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   236
    self.hatArray = nil;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   237
    self.secondaryItems = nil;
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   238
    self.teamDictionary = nil;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   239
    [super viewDidUnload];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   240
}
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
-(void) dealloc {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   244
    [secondaryItems release];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   245
    [hatArray release];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   246
    [teamDictionary release];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   247
    [super dealloc];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   248
}
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
@end
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   252