• 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
iPhone: Accessing variable from another view controller
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

iPhone: Accessing variable from another view controller


  • Subject: iPhone: Accessing variable from another view controller
  • From: "Eric E. Dolecki" <email@hidden>
  • Date: Fri, 21 Aug 2009 08:54:08 -0400

I have an application using a TabBar. The default view loaded and displayed
(so this loads up first): FirstViewController:

#import <UIKit/UIKit.h>


@interface FirstViewController : UIViewController {

@public BOOL availableNetwork;

}


@property (readonly) BOOL availableNetwork;


- (BOOL) isDataSourceAvailable;


@end



In this class in the awakeFromNib, I am doing a network availability test
and setting that availableNetwork BOOL. This works fine.



 - (void)awakeFromNib {

availableNetwork = NO;

BOOL returnVal = [self isDataSourceAvailable];

availableNetwork = returnVal;

}



In another view controller class, I'd like to access that variable. So what
I have tried in it's viewDidLoad:


 #import "FirstViewController.h"


in the viewDidLoad:


 FirstViewController *fvDelegate = (FirstViewController *)[[UIApplication
sharedApplication] delegate];

BOOL online = FirstViewController.availableNetwork;

error:accessing unknown 'availableNetwork' class method

NSLog( @"Online: %d", online );

*
*

How do I properly access that var? I think this delegate approach is totally
wrong, but I'm a bit new to Obj-C and don't know the right way to approach
this.
_______________________________________________

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: iPhone: Accessing variable from another view controller
      • From: Luke the Hiesterman <email@hidden>
  • Prev by Date: Re: When to 'release' in Cocoa management?
  • Next by Date: Re: When to 'release' in Cocoa management?
  • Previous by thread: Re: pulldown in custom NSCell
  • Next by thread: Re: iPhone: Accessing variable from another view controller
  • Index(es):
    • Date
    • Thread