Я пытался скопировать ввод текста из текстового поля alertview в NSMutableArray, который я буду использовать позже, всплывающее окно alertview выскакивает, и я ввожу ввод в текстовое поле, но когда я нажимаю OK, представление предупреждения исчезает, но не копирует текст в мой изменяемый массив
вот мой код
-(IBAction)add:(UIButton *)sender
{
addCustomStand = [[NSMutableArray alloc] init];
UIAlertView* dialog = [[UIAlertView alloc] initWithTitle:@"Enter a Stand Location"
message:@" "
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
UITextField *nameField = [[UITextField alloc]
initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
[nameField setBackgroundColor:[UIColor whiteColor]];
nameField.text = @"";
[dialog addSubview:nameField];
if ([nameField text]){
NSLog(@"Name Field %@ ",nameField.text);
[addCustomStand addObject:nameField.text];
}
[nameField release];
[dialog show];
[dialog release];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"OK"])
{
NSLog(@"Button 1 was selected.");
NSLog(@"StandLocations %@ ",addCustomStand);
}
}
вот мой вывод на экране журнала
2012-02-07 20:26:57.315 Avicii[1399:b603] Name Field
2012-02-07 20:26:59.720 Avicii[1399:b603] Button 1 was selected.
2012-02-07 20:26:59.721 Avicii[1399:b603] StandLocations (
""
)
кто-нибудь может помочь, что не так с этим кодом?