--- a/cocoaTouch/iPad/SingleTeamViewController.m Fri Apr 02 22:42:47 2010 +0000
+++ b/cocoaTouch/iPad/SingleTeamViewController.m Fri Apr 02 22:44:14 2010 +0000
@@ -7,10 +7,10 @@
//
#import "SingleTeamViewController.h"
-
+#import "HogHatViewController.h"
@implementation SingleTeamViewController
-@synthesize hogsList, secondaryItems;
+@synthesize hogsList, secondaryItems, teamName;
#pragma mark -
@@ -18,19 +18,12 @@
- (void)viewDidLoad {
[super viewDidLoad];
-
// Uncomment the following line to preserve selection between presentations.
//self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *teamFile = [[NSString alloc] initWithFormat:@"%@Teams/%@.plist",[paths objectAtIndex:0],self.title];
- NSDictionary *teamDict = [[NSDictionary alloc] initWithContentsOfFile: teamFile];
- [teamFile release];
- self.hogsList = [teamDict objectForKey:@"hedgehogs"];
- [teamDict release];
-
+
NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:
NSLocalizedString(@"Color",@""),
NSLocalizedString(@"Grave",@""),
@@ -43,11 +36,19 @@
}
-/*
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *teamFile = [[NSString alloc] initWithFormat:@"%@Teams/%@.plist",[paths objectAtIndex:0],self.teamName];
+ NSDictionary *teamDict = [[NSDictionary alloc] initWithContentsOfFile:teamFile];
+ [teamFile release];
+
+ self.hogsList = [teamDict objectForKey:@"hedgehogs"];
+ self.teamName = [teamDict objectForKey:@"teamname"];
+ [teamDict release];
+ self.title = teamName;
}
-*/
+
/*
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
@@ -64,9 +65,7 @@
}
*/
-
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- // Override to allow orientations other than the default portrait orientation.
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
@@ -74,13 +73,10 @@
#pragma mark -
#pragma mark Table view data source
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
- // Return the number of sections.
return 3;
}
-
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- // Return the number of rows in the section.
NSInteger rows;
switch (section) {
case 0:
@@ -98,24 +94,23 @@
return rows;
}
-
-// Customize the appearance of table view cells.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
+ reuseIdentifier:CellIdentifier] autorelease];
}
NSInteger row = [indexPath row];
switch ([indexPath section]) {
case 0:
- cell.textLabel.text = self.title;
+ cell.textLabel.text = teamName;
break;
case 1:
cell.textLabel.text = [[self.hogsList objectAtIndex:row] objectForKey:@"hogname"];
+ cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
break;
case 2:
cell.textLabel.text = [self.secondaryItems objectAtIndex:row];
@@ -172,14 +167,13 @@
#pragma mark Table view delegate
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- // Navigation logic may go here. Create and push another view controller.
- /*
- <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
- // ...
- // Pass the selected object to the new view controller.
- [self.navigationController pushViewController:detailViewController animated:YES];
- [detailViewController release];
- */
+ if (nil == hogChildController) {
+ hogChildController = [[HogHatViewController alloc] initWithStyle:UITableViewStyleGrouped];
+ }
+
+ hogChildController.hog = [hogsList objectAtIndex:[indexPath row]];
+ //NSLog(@"%@",hogChildController.hog);
+ [self.navigationController pushViewController:hogChildController animated:YES];
}
@@ -189,19 +183,20 @@
-(void) didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
-
// Relinquish ownership any cached data, images, etc that aren't in use.
}
-(void) viewDidUnload {
self.hogsList = nil;
self.secondaryItems = nil;
+ self.teamName = nil;
}
-(void) dealloc {
+ [secondaryItems release];
[hogsList release];
- [secondaryItems release];
+ [teamName release];
[super dealloc];
}