Global variable call working only first time

Posted by Ruthy on Stack Overflow See other posts from Stack Overflow or by Ruthy
Published on 2010-04-03T14:57:52Z Indexed on 2010/04/03 15:03 UTC
Read the original article Hit count: 308

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];
}

© Stack Overflow or respective owner

Related posts about cocoa

Related posts about iphone