Here is my code to display combo box:
self.records = [[NSMutableArray alloc]
initWithArray:[mylist componentsSeparatedByString:@","]];
[self.recordsCombo addItemsWithObjectValues:self.records];
Here is my code to display combo box:
self.records = [[NSMutableArray alloc]
initWithArray:[mylist componentsSeparatedByString:@","]];
[self.recordsCombo addItemsWithObjectValues:self.records];
You never sort comboBox's items. In fact you sort the array, which is the data source for the combo box.
As in your case you need to sort the self.records
and then addItems to combobox.
self.records = [[NSMutableArray alloc]
initWithArray:[mylist componentsSeparatedByString:@","]];
self.records = [self.records sortedArrayUsingSelector:@selector(compare:)];
[self.recordsCombo addItemsWithObjectValues:self.records];
Actually sorting alphabetically is covered already here: Sorting Array alphabetically
Otherwise you could alway implement your own sorting algorithm, like Quicksort or somewhat like this. Depends on your skills and needs.