I have a navigation based project and I want to be able to access properties in the different classes of the project.
In my appDelegate I have the property:
UINavigationController *navig;
and then I set the rootViewController:
MainViewController *theMainViewController = [[MainViewController alloc] init];
self.navig = [[UINavigationController alloc] initWithRootViewController:theMainViewController];
In the theMainViewController object I have the property:
MyScrollView *scrollView;
So, to access this scrollView property from a different class, I tried the following:
MyAppDelegate *myAppDelegate = (MyAppDelegate*) [UIApplication sharedApplication].delegate;
UIViewController *mainViewController = [myAppDelegate.navig.viewControllers objectAtIndex:0];
UIScrollView *scroll = mainViewController.scrollView;
However, it is not working. It doesn’t seems to find the scrollView property. Am I doing something wrong? Thanks very much!
How do you decline properties?
Also you should set appropriate type of
mainViewController: it should beMainViewController: