Here is the full code:
Code:
#import "RootViewController.h"
#import "TableViewAppDelegate.h"
#import "DetailViewController.h"
#import "DisclosureViewController.h"
@implementation RootViewController
- (void)viewDidLoad {
[super viewDidLoad];
listOfItems = [[NSMutableArray alloc] init];
[listOfItems addObject:@"Periodic Table"];
[listOfItems addObject:@"Acids & Bases"];
[listOfItems addObject:@"Metals"];
[listOfItems addObject:@"Water"];
self.navigationItem.title = @"Blah";
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; }
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return[listOfItems count];
}
- (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.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
NSString *cellValue =[listOfItems objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *selectedItem =[listOfItems objectAtIndex:indexPath.row];
NSString *glossary = @"Water";
if (selectedItem == glossary) {
DisclosureViewController *dsController = [[DisclosureViewController alloc] initWithNibName:@"DisclosureView" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dsController animated:YES];
[dsController release];
dsController = nil;
}
else {
DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
dvController.selectedItem = selectedItem;
[self.navigationController pushViewController:dvController animated:YES];
[dvController release];
dvController = nil;
}
}
- (void)dealloc {
[listOfItems release];
[selectedItem release];
[glossary release];
[super dealloc];
}
@end
There are also a couple of warnings about local declarations of 'selectedItem' and 'glossary' hiding the instance variable ould that have anything to do with it?
thanks again!