views:

13

answers:

1

I have an initial table view that I created as the initial menu within my app. Obviously each option will access something different including NIBs. Part of the constants for the menu options is the NIB. When each option is pulled from a PLIST, I also include which NIB I would like to be called upon.

Am I missing something or am I just going the wrong way entirely?

Right now a selection does nothing.

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

NSMutableString *targetnib = [[self.menuoptions objectAtIndex:indexPath.row] objectForKey:NIB_KEY];
if (targetnib == @"HospitalDirectoryViewController") {
    HospitalDirectoryViewController *hospitalDirectoryViewController = [[HospitalDirectoryViewController alloc] initWithNibName:@"HospitalDirectoryViewController" bundle:nil];
    // ...
    // Pass the selected object to the new view controller.
    [self.navigationController pushViewController:hospitalDirectoryViewController animated:YES];
    [hospitalDirectoryViewController release];
}
if (targetnib == @"PhysicianDirectoryViewController") {
PhysicianDirectoryViewController *physicianDirectoryViewController = [[PhysicianDirectoryViewController alloc] initWithNibName:@"PhysicianDirectoryViewController" bundle:nil];
 // ...
 // Pass the selected object to the new view controller.
 [self.navigationController pushViewController:physicianDirectoryViewController animated:YES];
 [physicianDirectoryViewController release];
}

}

A: 

Try using [targetnib isEqualToString: @"TheNibName"]. In your posted code, you're comparing pointers, not the text.

Darryl H. Thomas
That makes sense. However since it is expecting ( and ) I tried if ([targetnib isEqualtoString:@"DirectoryViewController"])I get a may not respond warning and it crashes when its run. So This seems like the right way, I am still messing up the syntax somewhere.
TheHockeyGeek
Maybe you just typed this wrong in the comment, but make sure the selector is isEqualToString: not isEqualtoString:, as you typed it.
Darryl H. Thomas
Also... is there a specific reason you're typing this as an NSMutableString as opposed to an NSString? NSMutableString will safely cast to NSString, but not vice-versa (need to make a mutableCopy if you truly want your string mutable).
Darryl H. Thomas
I changed it back to NSString. Not sure why I did mutable. The change of case isEqualtoString ---> isEqualToString fixed it. The little oversights are what get me.
TheHockeyGeek
Code completion FTW ;-)
Darryl H. Thomas