Reputation: 5442
I'm running Mac OS X Lion with xcode-4.2
In my AppDelegate.m in the application:didFinishLaunchingWithOptions method I have the following extract.
UIViewController *viewController1 = [[WSWFirstViewController alloc] initWithNibName:@"WSWFirstViewController" bundle:nil];
UIViewController *viewController2 = [[WSWSecondViewController alloc] initWithNibName:@"WSWSecondViewController" bundle:nil];
self.tabBarController = [[TabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
self.window.rootViewController = self.tabBarController;
[self.tabBarController showSplash];
[viewController1 displayItems];
What I'm trying to do is access the displayItems property of the viewController1 object which is of the type WSWFirstViewController.
In WSWFirstViewController.h I have
@property (retain, nonatomic) NSMutableArray *displayItems;
In WSWFirstViewController.m I have @synthesized displayItems.
I can't seem to figure out why I get a:
Property 'displayItems' not found on object of type 'UIViewController *'.
Until I noticed my object (viewController1) wasn't of the type UIViewController * but WSWFirstViewController *. But still that didn't help me any further.
Any advice is appreciated!
Upvotes: 0
Views: 1280
Reputation: 69047
You should refer your controllers by their proper type:
WSWFirstViewController *viewController1 = [[WSWFirstViewController alloc] initWithNibName:@"WSWFirstViewController" bundle:nil];
WSWSecondViewController *viewController2 = [[WSWSecondViewController alloc] initWithNibName:@"WSWSecondViewController" bundle:nil];
....
[viewController1 displayItems]; // this will now work if you are in the same context
Upvotes: 1