Question about scope
Question about scope
- Subject: Question about scope
- From: "Eric E. Dolecki" <email@hidden>
- Date: Thu, 26 Aug 2010 08:49:04 -0400
This is a noob question I'm sure.
I have a rootViewController. In it is a NSString thats been declared. The
rootViewController pushes another view onto the NavigationViewController...
loading that view. I'd like the loaded view to be able to access that string
variable. However, I am currently getting a null for it.
*RootViewController*
....
- (void)viewDidLoad {
myString = @"foo";
....
}
- (NSString *)getString {
return myString;
}
- (void)displaySecondView:(id)sender {
UIViewController *menuViewController = [[MenuViewController alloc]
init];
menuViewController.title = @"Menu";
self.navigationItem.backBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:@"Now Playing"
style: UIBarButtonItemStyleBordered
target:nil
action:nil];
[self.navigationController pushViewController:menuViewController
animated:YES];
[menuViewController release];
}
*And now the view being pushed...
*
in the .h I import RootViewController
RootViewController *rootViewController
@property(nonatomic,retain) RootViewController *rootViewController
----------
in the .m
@synthesize rootViewController
- (void)viewDidLoad {
NSString *tmp = [rootViewController getSourceLabel];
NSLog(@"%@",tmp); // (null)
}
All I want to do is access methods in the RootViewController...
Interactive Designer and Developer
Google Voice: (508) 656-0622
http://blog.ericd.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden