• 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
Re: Question about scope
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about scope


  • Subject: Re: Question about scope
  • From: Dave DeLong <email@hidden>
  • Date: Thu, 26 Aug 2010 07:52:19 -0600

Well to me it looks like you're never assigning anything into the second viewcontroller's rootViewController property, which means it'll be nil...

Dave

Sent from my iPhone

On Aug 26, 2010, at 7:50 AM, "Eric E. Dolecki" <email@hidden> wrote:

> 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
_______________________________________________

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

References: 
 >Question about scope (From: "Eric E. Dolecki" <email@hidden>)
 >Re: Question about scope (From: "Eric E. Dolecki" <email@hidden>)

  • Prev by Date: Re: Crashes in _Unwind_Resume
  • Next by Date: How to change name and location of "core dump files"
  • Previous by thread: Re: Question about scope
  • Next by thread: How to change name and location of "core dump files"
  • Index(es):
    • Date
    • Thread