I have an app with mulitple views. On view one I create and NSDate
as follows:
NSString *storeDate = [[NSDate date] description];
On view 2, in viewDidLoad:
I want to set the value of a label (outlet etc created and linked) to storeDate
value using
timeRecord.text = storeDate;
I have imported my views but storeDate
is being flagged as undeclared.
Any idea how I can get this to work?
SOFViewController.h
#import <UIKit/UIKit.h>
@interface SOFViewController : UIViewController {
}
-(IBAction) storeDateBut: (id) sender;
-(IBAction) goToView2: (id) sender;
@property (nonatomic,retain) NSString *storeDate;
@end
SOFViewController.m
#import "SOFViewController.h"
#import "view2.h"
@implementation SOFViewController
@synthesize storeDate;
-(IBAction) storeDateBut: (id) sender{
self.storeDate = [[NSDate date] description];
}
-(IBAction) goToView2: (id) sender{
view2 *myview2 = [[view2 alloc] initWithNibName:@"view2" bundle:nil];
[self.view addSubview:myview2.view];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload {
}
- (void)dealloc {
[super dealloc];
}
@end
view2.h
#import <UIKit/UIKit.h>
@interface view2 : UIViewController {
IBOutlet UILabel *dateLabel;
}
-(IBAction) goToView1: (id) sender;
@property (nonatomic, retain) IBOutlet UILabel *dateLabel;
@end
view2.m
#import "view2.h"
#import "SOFViewController.h"
@implementation view2
@synthesize dateLabel;
-(IBAction) goToView1: (id) sender{
SOFViewController *mySOFViewController = [[SOFViewController alloc] initWithNibName:@"view2" bundle:nil];
[self.view addSubview:mySOFViewController.view];
}
- (void)viewDidLoad {
dateLabel.text = SOFViewController.storeDate;
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload {
[super viewDidUnload];
}
- (void)dealloc {
[super dealloc];
}
@end