Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // self.array is an array with controllers of difrent classes.
  2. // self array is initialized from a plist of NSStrings which contain the name of classes.
  3. // if the class name is from 2 words i want to know how can i init the correct nib name?
  4. // on the console i get the message: "Application tried to push a nil view controller on target"
  5. // how can i fix this?
  6.  
  7.  
  8. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  9. {
  10.     NSLog(@"%@",self.array);
  11.     NSString *name = [self.array objectAtIndex: [indexPath row]];
  12.     if([name compare: @"Third Controller"] == YES)
  13.     {
  14.         id controller = [[NSClassFromString(name) alloc] initWithNibName: @"ThirdController" bundle: nil];
  15.         [controller setTitle: name];
  16.         [self.navigationController pushViewController: controller animated:YES];
  17.         [controller release];
  18.         return;
  19.     }  
  20.     id controller = [[NSClassFromString(name) alloc] initWithNibName: name bundle: nil];
  21.     [controller setTitle: name];
  22.     [self.navigationController pushViewController: controller animated:YES];
  23.     [controller release];
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement