views:

27

answers:

1

hello i am wondering how its possible to load a nib depending on the string selected from the cell title. here is the code that i am using however i cant get any results..

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

 //FinalViewController *anotherViewController = [[FinalViewController alloc] initWithNibName:@"FinalViewController" bundle:nil];

 if ([[tableView cellForRowAtIndexPath: indexPath].textLabel.text isEqualToString: @"Ath 1"])
 {          
     LastViewController *lastViewController = [[LastViewController alloc]
                         initWithNibName:@"LastViewController" bundle:nil];

i dont understand why this doesnt work?

A: 

I'd firstly test to see if your code

if ([[tableView cellForRowAtIndexPath: indexPath].textLabel.text isEqualToString: @"Ath 1"])

actually works. I'd say this is your first hurdle.

Once you can confirm that it is going onto the next stage, creating your view controller, you can start debugging that. I'd put an NSLog above where you create your lastViewController and check to see if your if statement works.

Bongeh
yes i tried it with nslog and it works...
Alex
okay, what code do you have after LastViewController *lastViewController = [[LastViewController alloc] initWithNibName:@"LastViewController" bundle:nil];You have allocated and initialized the viewcontroller, but are your presentingit as a modal controller? are you pushing it in a navigation controller?
Bongeh
nvm i solved this problem. i had a missing pushcontroller ...
Alex
exactly what i just said, glad ur issue is resolved.
Bongeh