I'm trying to add UITextField
input into an NSMutableArray
using the following IBActions
, connected to the 'did end editing' part of the 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);
}
and I've initialized the players array in the viewDidLoad
section like so:
- (void)viewDidLoad
{
[super viewDidLoad];
players = [[NSMutableArray alloc] init];
}
but the array remains 'nil'. Anyone know how to fix this?