Global variable call working only first time
- by Ruthy
Hello, I defined a global variable that is called from other view and it is working first time but not following ones, it keeps with value from first call! Suppose that is a cocoa fundamental problem and variable is not properly defined according its need. Thanks for any idea to solve it.
declaration:
@interface TableArchiveAppDelegate : NSObject <UIAppDelegate> {
NSString *varName;
}
@property (nonatomic, copy) NSString *varName;
then related lines on .m file:
@synthesize varName;
-(void)test{
varName = textField.text;
}
and request from another view:
- (void)viewDidLoad {
TableArchiveAppDelegate *mainDelegate = (TableArchiveAppDelegate *)[[UIApplication sharedApplication] delegate];
name.text = mainDelegate.varName;
[super viewDidLoad];
}