Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 01-10-2010, 11:43 PM   #8 (permalink)
Sentis
Registered Member
 
Join Date: Oct 2009
Posts: 9
Sentis is on a distinguished road
Default

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!

Last edited by Sentis; 01-10-2010 at 11:49 PM.
Sentis is offline   Reply With Quote
 

» Advertisements
» Online Users: 460
12 members and 448 guests
Abidullah, antonwilliams, ArthurOff, Arty Tales, David-T, ilmman, kamrul00gg, magdaleneei61, schmallegory, simplymuzik3, Sloshmonster, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,429
Threads: 94,024
Posts: 402,577
Top Poster: BrianSlick (7,978)
Welcome to our newest member, magdaleneei61
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:40 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.