我正在尝试使用以下连接到“已结束编辑”部分将UITextField
输入添加到:NSMutableArray
IBActions
UITextFields
- (IBAction) returnKey1
{
[textInputOne addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
[textInputOne resignFirstResponder];
[players addObject:textInputOne.text];
}
- (IBAction) returnKey2
{
[textInputTwo addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
[textInputTwo resignFirstResponder];
[players addObject:textInputTwo.text];
NSLog(@"array: %@",players);
}
我已经在viewDidLoad
部分中初始化了 player 数组,如下所示:
- (void)viewDidLoad
{
[super viewDidLoad];
players = [[NSMutableArray alloc] init];
}
但数组仍然是“零”。有人知道怎么修这个东西吗?