An answer posted for one of my previous questions brings up anoth开发者_JAVA技巧er 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.
You've declared the rootViewController property as a UITableViewController (which does not have a "contacts" property).
Most likely, your root view controller is a subclass of UITableViewController. If you called that subclass RootViewController, then the rootViewController property in RuleBuilder should be declared as
RootViewController *rootViewController
精彩评论