Using (void)awakeFromNib
Posted
by MN
on Stack Overflow
See other posts from Stack Overflow
or by MN
Published on 2010-04-15T02:08:46Z
Indexed on
2010/04/15
2:13 UTC
Read the original article
Hit count: 279
iphone
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; }
}
© Stack Overflow or respective owner