iphone - accessing the navigation controller from separate delegate class -


I'm a tutorial follwing a book and there are different representative data source controller (MyViewController.m) < the / p>

  [self setDataSource: [[MyViewDataSource alloc] [self setDelegate: [[MyViewDelegate alloc]  

in order to understand, I no longer representative of a controller pop to class (MyViewDelegate.m)

  - (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath {2ndViewController * controller = [[2ndViewController alloc]]; [[Nav NavController] pushViewController: Animated Controller: Yes];  

Of course this will not work since the NIT controller sits in the app delegate. But how do I navacroller from delegate class I can use best?

You can do something like

  Uaiawhiajintrniyntrk * Navientrolr = [(Mappelgate *) [[UIApplication ShareApp] Rep] navigation controller];  

However, you do more with myself should ask is why you need to do and if better way to MVC (Model View Controller) and rules of Encapsulation. For example

, UIViewController has been described by the documentation as submitted designate a property is navigationController , which, given the view controller The appropriate navigation controller will return.


Comments