Normally i've been passing variable around in init methods, but I can't do that this time because I have a var in one ViewController class displayed using a tab bar and I need access to it from a different ViewController class when a different tab bar is pressed. My understanding was that you can access vars using @property but it's now working so I'm doing something wrong. Here is what I have:
Class 1 Header file
@interface DailyViewController : UIViewController <UIActionSheetDelegate> {
NSDate *today;
}
@property (readwrite, nonatomic, retain) NSDate *today;
Class 2 implementation file:
- (void)viewWillAppear:(BOOL)animated{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterLongStyle];
[formatter setTimeStyle:NSDateFormatterNoStyle];
DailyViewController *otherClass = [[DailyViewController alloc] init];
NSString* todayString = [formatter stringFromDate:otherClass.today];
r_todayLabel.text = todayString;
[otherClass release];
[formatter release];
}