这是我显示组合框的代码:
self.records = [[NSMutableArray alloc]
initWithArray:[mylist componentsSeparatedByString:@","]];
[self.recordsCombo addItemsWithObjectValues:self.records];
最佳答案
你永远不会对组合框的项目进行排序。事实上,您对数组进行排序,该数组是组合框的数据源。
就像您的情况一样,您需要对 self.records
进行排序,然后将Items 添加到组合框。
self.records = [[NSMutableArray alloc]
initWithArray:[mylist componentsSeparatedByString:@","]];
self.records = [self.records sortedArrayUsingSelector:@selector(compare:)];
[self.recordsCombo addItemsWithObjectValues:self.records];
关于objective-c - 如何对 NSComboBox 内容进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27396844/