我可以在iphone目标c的警报中使用NSStrings吗?

snr*_*brn 1 iphone objective-c alerts nsstring

我正在尝试创建一个用户单击按钮的应用程序,并弹出一个警告,其中包含文本字段中的文本.但每当我尝试,我只是得到一个空白的警报.这是我的代码:

@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;
}
Run Code Online (Sandbox Code Playgroud)

我做错了什么似乎一切都到位应有的样子.我认为答案可能与NSLog()有关.

Chu*_*uck 6

您在显示警报设置了该text属性.创建警报时,可能设置为.nil