0

I have a Combobox contains 30 items (1,2,...,30). I want to select item in Combobox, create dynamic NSTextField same item selected in Combobox. Then user input text to NSTextField, and then click on button to get all text of each NSTextField add to NSMutableArray. I use bellow code to get text from NSTextField and add it to Array but it can only get from 1 NSTextField:

NSMutableArray * SSID_Arr = [[NSMutableArray alloc] initWithCapacity:x];
[SSID_Arr addObject:ssidtxt.stringValue]; // get text from NSTextField
NSLog (@"SSID_Arr : %@",SSID_Arr);

NSString *strSSID;
for(int j=0; j < [SSID_Arr count]; j++)
{
    strSSID = [NSString stringWithFormat:@"\r\nSSID : %@", [SSID_Arr objectAtIndex:j]];
}

Do you have suggestion? Thanks in advance

beryllium
  • 29,669
  • 15
  • 106
  • 125
HTKT611
  • 161
  • 1
  • 1
  • 11

2 Answers2

0

just make

NSMutableArray *SSID_Arr = [NSMutableArray new];
Jeremy Piednoel
  • 407
  • 2
  • 5
  • 12
0
NSMutableArray * SSID_Arr = [[NSMutableArray alloc] initWithCapacity:x];

gives an array with space reserved for x values.But there is no value in that position right now

So first fill up the array via a loop and then continue as

NSMutableArray * SSID_Arr = [[NSMutableArray alloc] initWithCapacity:x];
for (int i=0; i<x; i++) {
    [SSID_Arr addObject:ssidtxt.stringValue]; 
}

Now the array contains x values and you can proceed.Please note the one textfield value is getting populated here x times.If you have to store all textfield values ,write a loop suitable to achieve all values and add it

Lithu T.V
  • 19,955
  • 12
  • 56
  • 101