Using (void)awakeFromNib
- by MN
I am trying to run an action when the application starts. The action checkAtStart is supposed to display an alert if there is no text in field1 and hide startView if there is text in field1. checkAtStart works fine if assigned to a button, but when I try to run it using (void)awakeFromNib, the alert will display no matter what and startView will never hide. Its probably something really simple that I'm forgetting. Any help is appreciated!
Here is my code:
- (void)awakeFromNib {
[self checkAtStart:self];
}
- (IBAction)checkAtStart:(id)sender
{
if (field1.text == nil || [field1.text isEqualToString:@""])
{
NSString *msg = nil;
msg = nil;
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Test Message"
message:@"Test Message"
delegate:self
cancelButtonTitle:@"Close"
otherButtonTitles: nil];
[alert show];
[alert release];
[msg release];
}
else
{
startView.hidden = YES;
}
}