cocoaTouch/iPad/TeamSettingsViewController.m
author koda
Fri, 02 Apr 2010 15:08:43 +0000
changeset 3251 221c163ad5d9
parent 3250 d5cd1a617123
child 3253 b0b1b1310b7e
permissions -rw-r--r--
continue working for team support on the ifrontend
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     1
//
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     2
//  TeamSettingsViewController.m
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     3
//  HedgewarsMobile
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     4
//
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     5
//  Created by Vittorio on 02/04/10.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     7
//
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     8
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
     9
#import "TeamSettingsViewController.h"
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    10
#import "SingleTeamViewController.h"
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    11
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    12
@implementation TeamSettingsViewController
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    13
@synthesize list;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    14
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    15
#pragma mark -
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    16
#pragma mark View lifecycle
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    17
- (void)viewDidLoad {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    18
    [super viewDidLoad];
3251
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    19
    
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    20
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    21
    NSString *teamsDirectory = [[paths objectAtIndex:0] stringByAppendingString:@"Teams/"];
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    22
    
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    23
    NSArray *contents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:teamsDirectory
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    24
                                                                            error:NULL];
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    25
    //NSArray *array = [[NSArray alloc] initWithObjects:@"Toy Story", @"A Bug's Life", @"Toy Story 2", 
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    26
    //                  @"Monsters, Inc.",@"Finding Nemo", @"The Incredibles", @"Cars", @"Ratatouille", 
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    27
    //                  @"WALL-E", @"Up", @"Toy Story 3", @"Cars 2", @"The Bear and the Bow", @"Newt", nil];
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    28
    self.list = contents;
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    29
   
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    30
    // Uncomment the following line to preserve selection between presentations.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    31
    self.clearsSelectionOnViewWillAppear = NO;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    32
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    33
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    34
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    35
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    36
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    37
    // Override to allow orientations other than the default portrait orientation.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    38
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    39
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    40
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    41
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    42
#pragma mark -
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    43
#pragma mark Table view data source
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    44
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    45
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    46
    // Return the number of sections.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    47
    return 1;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    48
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    49
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    50
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    51
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    52
    // Return the number of rows in the section.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    53
    return [list count];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    54
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    55
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    56
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    57
// Customize the appearance of table view cells.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    58
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    59
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    60
    static NSString *CellIdentifier = @"Cell";
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    61
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    62
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    63
    if (cell == nil) {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    64
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    65
    }
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    66
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    67
    NSUInteger row = [indexPath row]; 
3251
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    68
    NSString *rowString = [[list objectAtIndex:row] stringByDeletingPathExtension]; 
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    69
    cell.textLabel.text = rowString; 
3251
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    70
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    71
    //cell.imageView.image = [UIImage imageNamed:@"Default.png"];
3251
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    72
    //[rowString release];
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    73
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    74
    return cell;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    75
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    76
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    77
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    78
/*
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    79
// Override to support conditional editing of the table view.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    80
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    81
    // Return NO if you do not want the specified item to be editable.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    82
    return YES;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    83
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    84
*/
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    85
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    86
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    87
/*
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    88
// Override to support editing the table view.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    89
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    90
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    91
    if (editingStyle == UITableViewCellEditingStyleDelete) {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    92
        // Delete the row from the data source
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    93
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    94
    }   
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    95
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    96
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    97
    }   
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    98
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
    99
*/
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   100
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   101
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   102
/*
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   103
// Override to support rearranging the table view.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   104
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   105
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   106
*/
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   107
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   108
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   109
/*
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   110
// Override to support conditional rearranging of the table view.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   111
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   112
    // Return NO if you do not want the item to be re-orderable.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   113
    return YES;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   114
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   115
*/
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   116
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   117
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   118
#pragma mark -
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   119
#pragma mark Table view delegate
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   120
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   121
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
3251
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   122
 if (childController == nil) {
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   123
        childController = [[SingleTeamViewController alloc] initWithStyle:UITableViewStyleGrouped];
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   124
    }
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   125
    
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   126
    NSInteger row = [indexPath row];
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   127
    NSString *selectedMovie = [[list objectAtIndex:row] stringByDeletingPathExtension];
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   128
    NSString *detailMessage = [[NSString alloc] initWithFormat:@"you pressed the button for %@", selectedMovie];
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   129
3251
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   130
    childController.title = selectedMovie;
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   131
    [detailMessage release];
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   132
    [self.navigationController pushViewController:childController animated:YES];
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   133
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   134
}
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   135
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   136
/*
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   137
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   138
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Hey, do you see the disclosure button?" 
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   139
                                                    message:@"If you're trying to drill down, touch that instead" 
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   140
                                                   delegate:nil
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   141
                                          cancelButtonTitle:@"Won't happen again"
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   142
                                          otherButtonTitles:nil];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   143
    [alert show];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   144
    [alert release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   145
}
3251
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
   146
*/
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   147
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   148
#pragma mark -
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   149
#pragma mark Memory management
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   150
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   151
- (void)didReceiveMemoryWarning {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   152
    // Releases the view if it doesn't have a superview.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   153
    [super didReceiveMemoryWarning];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   154
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   155
    // Relinquish ownership any cached data, images, etc that aren't in use.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   156
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   157
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   158
/*
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   159
- (void)viewDidUnload {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   160
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   161
    // For example: self.myOutlet = nil;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   162
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   163
*/
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   164
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   165
- (void)dealloc {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   166
    [list release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   167
    if (nil != childController)
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   168
        [childController release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   169
    [super dealloc];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   170
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   171
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   172
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   173
@end
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents:
diff changeset
   174