How do I get a reference to a rootViewController to a sub-view?
Posted
by Andy
on Stack Overflow
See other posts from Stack Overflow
or by Andy
Published on 2010-04-16T20:47:34Z
Indexed on
2010/04/16
21:13 UTC
Read the original article
Hit count: 144
An answer posted for one of my previous questions brings up another question; I am calling a new view controller, "RuleBuilder," from my rootViewController. The rootViewController holds a reference to a contacts array. How do I get a reference to that array into the RuleBuilder? I tried adding
UITableViewController *rootViewController;
...
@property (nonatomic, retain) UITableViewController *rootViewController;
to RuleBuilder.h, and then
@synthesize rootViewController;
in RuleBuilder.m. When I instantiate and push the RuleBuilder from within rootViewController, I do this:
ruleBuilder.rootViewController = self;
But when I try this
[rootViewController.contacts addObject:newContact];
from within RuleBuilder, I get a compiler error to the effect of "request for 'contacts' in something not a struct" (or very similar; I haven't implemented this exact snippet of code, but I tried an identical approach not an hour ago for a couple of different references that I never was able to get working).
Thanks, again, for your help.
© Stack Overflow or respective owner