PDA

View Full Version : Accessing properties of properties




luckylefty01
Jun 23, 2008, 10:44 PM
I've got something that kind of stumps me.

In my iPhone app delegate I have this code, which works (accessing the view property of the UIViewController MainViewController):

MainViewController *mainViewController =
(MainViewController*)rootViewController.mainViewController;
MainView *mainView = (MainView *)[mainViewController view];


What I originally wanted to do was:

MainView *mainView = rootViewController.mainViewController.view;

which fails with an "error: accessing unknown 'view' component of a property."

Can anybody enlighten me as to why?



Catfish_Man
Jun 23, 2008, 11:11 PM
Is your mainViewController property declared as being a MainViewController* ?

tacoman667
Jun 24, 2008, 12:32 AM
I've got something that kind of stumps me.

In my iPhone app delegate I have this code, which works (accessing the view property of the UIViewController MainViewController):

MainViewController *mainViewController =
(MainViewController*)rootViewController.mainViewController;
MainView *mainView = (MainView *)[mainViewController view];


What I originally wanted to do was:

MainView *mainView = rootViewController.mainViewController.view;

which fails with an "error: accessing unknown 'view' component of a property."

Can anybody enlighten me as to why?

Have you tried: MainView *mainView = [rootViewController.mainViewController view];

luckylefty01
Jun 24, 2008, 11:33 PM
Is your mainViewController property declared as being a MainViewController* ?

*sigh*

Thanks. In my app delegate I had imported the root view controller and the main view itself, but the main view controller had been left out.