views:

229

answers:

1

I can't seem to access parent view properties in a navigation stack. See below

//the parent to current view (which is at index 2)
UIViewController *parentView = [self.navigationController.viewControllers objectAtIndex:1];
//there is an NSArray propery called games in parentView
NSLog(@"%@",[parentView.games]);

This code gets the error that "Request for member gametypes in something not a structure or union" which is what happens when you use dot syntax with a property that is not synthesized.

+1  A: 

You should cast parentView to the type it is rather than just UIViewController.

You can do it like this:

ParentViewType *parentView = (ParentViewType*) [self.navigationController.viewControllers objectAtIndex:1];
NSLog(@"%@",[parentView.games]);
dbachrach
That worked like a charm. It's so obvious, too. Thanks for taking the time to answer.
JustinXXVII