21 |
21 |
22 #import "StatsPageViewController.h" |
22 #import "StatsPageViewController.h" |
23 #import "CommodityFunctions.h" |
23 #import "CommodityFunctions.h" |
24 |
24 |
25 @implementation StatsPageViewController |
25 @implementation StatsPageViewController |
26 @synthesize statsDictionary; |
26 @synthesize statsArray; |
27 |
27 |
28 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
28 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
29 return rotationManager(interfaceOrientation); |
29 return rotationManager(interfaceOrientation); |
30 } |
30 } |
31 |
31 |
32 #pragma mark - |
32 #pragma mark - |
33 #pragma mark Table view data source |
33 #pragma mark Table view data source |
34 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
34 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
35 return 2; |
35 return 3; |
36 } |
36 } |
37 |
37 |
38 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
38 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
39 if (section == 0) |
39 if (section == 0 || section == 2) |
40 return [[self.statsDictionary allValues] count]; |
40 return 1; |
41 else |
41 else |
42 return 1; |
42 return [self.statsArray count] - 1; |
43 } |
43 } |
44 |
44 |
45 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
45 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
46 static NSString *CellIdentifier0 = @"Cell0"; |
46 static NSString *CellIdentifier0 = @"Cell0"; |
|
47 NSInteger section = [indexPath section]; |
|
48 NSInteger row = [indexPath row]; |
47 |
49 |
48 UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
50 UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
49 if (cell == nil) |
51 if (cell == nil) |
50 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0] autorelease]; |
52 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0] autorelease]; |
51 |
53 |
52 cell.textLabel.textAlignment = UITextAlignmentCenter; |
54 cell.textLabel.textAlignment = UITextAlignmentCenter; |
53 if ([indexPath section] == 0) { |
55 if (section == 0) { |
54 cell.textLabel.text = [[self.statsDictionary allValues] objectAtIndex:[indexPath row]]; |
56 cell.textLabel.text = [self.statsArray objectAtIndex:row]; |
|
57 } else if (section == 1) { |
|
58 cell.textLabel.text = [self.statsArray objectAtIndex:row + 1]; |
55 } else { |
59 } else { |
56 cell.textLabel.text = NSLocalizedString(@"Back",@""); |
60 cell.textLabel.text = NSLocalizedString(@"Back",@""); |
57 } |
61 } |
58 |
62 |
59 return cell; |
63 return cell; |
60 } |
64 } |
61 |
|
62 |
65 |
63 #pragma mark - |
66 #pragma mark - |
64 #pragma mark Table view delegate |
67 #pragma mark Table view delegate |
65 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
68 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
66 if ([indexPath section] == 2) |
69 if ([indexPath section] == 2) |
70 #pragma mark - |
73 #pragma mark - |
71 #pragma mark Memory management |
74 #pragma mark Memory management |
72 -(void) didReceiveMemoryWarning { |
75 -(void) didReceiveMemoryWarning { |
73 // Releases the view if it doesn't have a superview. |
76 // Releases the view if it doesn't have a superview. |
74 [super didReceiveMemoryWarning]; |
77 [super didReceiveMemoryWarning]; |
75 // Relinquish ownership any cached data, images, etc. that aren't in use. |
78 self.statsArray = nil; |
76 } |
79 } |
77 |
80 |
78 -(void) dealloc { |
81 -(void) dealloc { |
79 [statsDictionary release]; |
82 [statsArray release]; |
80 [super dealloc]; |
83 [super dealloc]; |
81 } |
84 } |
82 |
85 |
83 |
86 |
84 @end |
87 @end |