• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Question about scope
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Question about scope
      • From: "Eric E. Dolecki" <email@hidden>
  • Prev by Date: [OT]making app new modules display from within the app and not from the app store.
  • Next by Date: Re: NSCoding between iOS and Mac OS X
  • Previous by thread: Re: [OT]making app new modules display from within the app and not from the app store.
  • Next by thread: Re: Question about scope
  • Index(es):
    • Date
    • Thread