Hi,
I have a NSString member variable declared in the header file of the view controller:
@interface MyApprViewController : UIViewController {
NSString *var;
...
}
@property (retain) NSString *var;
...
-(IBAction)buttonPressed: (id)sender;
Inside the implementation, I use @synthesize var
and try to use that var from within the implementation of the buttonPressed method, but it does not work properly and I assume it is because var was never initialized. Where can I initialize this variable? I do not want to do it inside the method; I want to do it once of course, because I will keep appending text to it:
-(IBAction)buttonPressed: (id)sender {
NSString *input = ((UIButton *)sender).currentTitle;
var = [var stringByAppendingString:input];
textField.text = var;
}
[input release];
}
I tried overriding the init method inside the view controller class, but it never gets called (maybe because there is no explicit initialization of the view controller class?) So, where should I initialize var
so that I can use it inside the view controller class (inside the buttonPressed method)?
Thanks, Mihai