views:

53

answers:

1

I am trying to make an app where the user clicks a button and an alert pops up with the text from a textfield in it. But whenever i try, i just get a blank alert. This is my code:

@synthesize label;

@synthesize textBox1;

@synthesize text;

- (IBAction)buttonClick {
 UIAlertView *someText = [[UIAlertView alloc] initWithTitle: @"Text from textbox1" message: text delegate: self cancelButtonTitle: @"OK" otherButtonTitles: nil];
 [someText show];
 [someText release];
 text = textBox1.text;
 label.text = text;
}

what am i doing wrong it seems like everything is in place like it should be. I think the answer might have something to do with NSLog().

+6  A: 

You're setting the text property after you show the alert. When the alert is created, it's probably set to nil.

Chuck