referencing an instantiated object in another class in objective C

Posted by Paul on Stack Overflow See other posts from Stack Overflow or by Paul
Published on 2010-03-19T23:15:16Z Indexed on 2010/03/19 23:21 UTC
Read the original article Hit count: 468

hi, I am working in xcode on an ipod app in objective C, and I have a field (navigationController) in one of my classes (rootViewController). How do I reference the instantiated rootViewController's navigationController from another class? For example, how would I do this if I want to reference the navigationController from the FirstViewController.m class?

I seem to only be able to find references for this to reference the application delegate.

If I want to reference the application delegate with FirstViewController, I just say:

MyAppDelegate *delegate = [[UIApplication sharedApplication] delegate];

[delegate.navigationController pushViewController:childController animated:YES];

how do I do this for the rootViewController class instead of MyAppDelegate?

© Stack Overflow or respective owner

Related posts about navigationcontroller

Related posts about uiapplicationdelegate