iPhone: Accessing variable from another view controller
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