cocoaTouch/SingleTeamViewController.m
author koda
Thu, 08 Apr 2010 02:35:40 +0000
changeset 3323 091cf214bdd5
parent 3316 52f0482b043f
child 3325 652a8ebdf667
permissions -rw-r--r--
implement an add/remove team in the ifrontend
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
    
3323
091cf214bdd5 implement an add/remove team in the ifrontend
koda
parents: 3316
diff changeset
    37
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    38
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    39
    // 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
    40
    [[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
    41
    isWriteNeeded = NO;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    42
}
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    43
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    44
- (void)viewWillAppear:(BOOL)animated {
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    45
    [super viewWillAppear:animated];
3323
091cf214bdd5 implement an add/remove team in the ifrontend
koda
parents: 3316
diff changeset
    46
    
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    47
    self.title = [self.teamDictionary objectForKey:@"teamname"];
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    48
    
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    49
    // 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
    50
    NSArray *hogArray = [self.teamDictionary objectForKey:@"hedgehogs"];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    51
    NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:[hogArray count]];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    52
    for (NSDictionary *hog in hogArray) {
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    53
        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
    54
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    55
        UIImage *image = [[UIImage alloc] initWithContentsOfFile: hatFile];
3316
52f0482b043f fix a couple of leaks in hte ifrontend
koda
parents: 3315
diff changeset
    56
        [hatFile release];
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    57
        CGRect firstSpriteArea = CGRectMake(0, 0, 32, 32);
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    58
        CGImageRef cgImgage = CGImageCreateWithImageInRect([image CGImage], firstSpriteArea);
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    59
        [image release];
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    60
        
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    61
        UIImage *hatSprite = [[UIImage alloc] initWithCGImage:cgImgage];
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    62
        [array addObject:hatSprite];
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    63
        CGImageRelease(cgImgage);
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    64
        [hatSprite release];
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    65
    }
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    66
    self.hatArray = array;
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
    67
    [array release];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    68
    
3323
091cf214bdd5 implement an add/remove team in the ifrontend
koda
parents: 3316
diff changeset
    69
    [self.tableView setContentOffset:CGPointMake(0,0) animated:NO];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    70
    [self.tableView reloadData];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    71
}
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
- (void)viewDidAppear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    75
    [super viewDidAppear:animated];
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
*/
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    78
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    79
-(void) setWriteNeeded {
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    80
    isWriteNeeded = YES;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    81
}
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    82
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    83
// write to disk the team dictionary
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    84
-(void) viewWillDisappear:(BOOL)animated {
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    85
    [super viewWillDisappear:animated];
3315
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
    if (isWriteNeeded) {
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    88
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    89
        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
    90
        [self.teamDictionary writeToFile: teamFile atomically:YES];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    91
        [teamFile release];
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
        isWriteNeeded = NO;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    94
    }
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    95
}
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
    96
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    97
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    98
- (void)viewDidDisappear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    99
    [super viewDidDisappear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   100
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   101
*/
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
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   104
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
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
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   109
#pragma mark Table view data source
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   110
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   111
    return 3;
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
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3308
diff changeset
   115
    NSInteger rows = 0;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   116
    switch (section) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   117
        case 0:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   118
            rows = 1;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   119
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   120
        case 1:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   121
            rows = 8;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   122
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   123
        case 2:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   124
            rows = 6;
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
        default:
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
    }
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   129
    return rows;
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
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   132
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   133
    static NSString *CellIdentifier = @"Cell";
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
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   136
    if (cell == nil) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   137
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   138
                                       reuseIdentifier:CellIdentifier] autorelease];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   139
    }
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   140
    NSArray *hogArray;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   141
    NSInteger row = [indexPath row];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   142
    switch ([indexPath section]) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   143
        case 0:
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   144
            cell.textLabel.text = self.title;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   145
            cell.imageView.image = nil;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   146
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   147
        case 1:
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   148
            hogArray = [self.teamDictionary objectForKey:@"hedgehogs"];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   149
            cell.textLabel.text = [[hogArray objectAtIndex:row] objectForKey:@"hogname"];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   150
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   151
            cell.imageView.image = [self.hatArray objectAtIndex:row];
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 2:
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   154
            cell.textLabel.text = [self.secondaryItems objectAtIndex:row];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   155
            cell.imageView.image = nil;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   156
            break;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   157
        default:
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
    }
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
    return cell;
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   162
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   163
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
// Override to support conditional editing of the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   167
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   168
    // 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
   169
    return YES;
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
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   173
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   174
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   175
// Override to support editing the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   176
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
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
    if (editingStyle == UITableViewCellEditingStyleDelete) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   179
        // Delete the row from the data source
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   180
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   181
    }   
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   182
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   183
        // 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
   184
    }   
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   185
}
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
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
// Override to support rearranging the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   191
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
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
/*
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   197
// Override to support conditional rearranging of the table view.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   198
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   199
    // 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
   200
    return YES;
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
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
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   206
#pragma mark Table view delegate
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   207
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   208
    if (1 == [indexPath section]) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   209
        if (nil == hogChildController) {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   210
            hogChildController = [[HogHatViewController alloc] initWithStyle:UITableViewStyleGrouped];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   211
        }
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   212
        
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   213
        // 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
   214
        hogChildController.teamDictionary = self.teamDictionary;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   215
        hogChildController.selectedHog = [indexPath row];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   216
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   217
        [self.navigationController pushViewController:hogChildController animated:YES];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   218
    }
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   219
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   220
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   221
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   222
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   223
#pragma mark Memory management
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   224
-(void) didReceiveMemoryWarning {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   225
    // Releases the view if it doesn't have a superview.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   226
    [super didReceiveMemoryWarning];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   227
    // Relinquish ownership any cached data, images, etc that aren't in use.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   228
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   229
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   230
-(void) viewDidUnload {
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   231
    self.hatArray = nil;
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   232
    self.secondaryItems = nil;
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   233
    self.teamDictionary = nil;
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   234
    [super viewDidUnload];
3305
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
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   237
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   238
-(void) dealloc {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   239
    [secondaryItems release];
3315
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   240
    [hatArray release];
4e2813713358 usa a cached dictionary and write only when needed
koda
parents: 3312
diff changeset
   241
    [teamDictionary release];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   242
    [super dealloc];
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
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   245
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   246
@end
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   247