Re: Question about scope
Re: Question about scope
- Subject: Re: Question about scope
- From: "Eric E. Dolecki" <email@hidden>
- Date: Thu, 26 Aug 2010 09:50:04 -0400
What I have done is when instantiating the viewcontroller to push into the
navigationviewcontroller is to call a method on the viewcontroller before
the push, thus setting the var and not trying to attempt a get. It works.
Still curious about the get though - can that be done?
Interactive Designer and Developer
Google Voice: (508) 656-0622
http://blog.ericd.net
On Thu, Aug 26, 2010 at 8:49 AM, Eric E. Dolecki <email@hidden> wrote:
> 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