没有可以从中获取此内置方法。但是简单的逻辑对您有用。准备字典时,您只需在每个键的前面添加一些数字文本即可。喜欢
NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:
@"01.Created",@"cre",
@"02.Being Assigned",@"bea",
@"03.Rejected",@"rej",
@"04.Assigned",@"ass",
@"05.Scheduled",@"sch",
@"06.En Route",@"inr",
@"07.On Job Site",@"ojs",
@"08.In Progress",@"inp",
@"09.On Hold",@"onh",
@"10.Completed",@"com",
@"11.Closed",@"clo",
@"12.Cancelled", @"can",
nil];
现在,如果您可以使用sortingArrayUsingSelector并以与放置相同的顺序获取所有键。
NSArray *arr = [[dict allKeys] sortedArrayUsingSelector:@selector(localizedStandardCompare:)];
在要在UIView中显示键的地方,只需将前3个字符切掉即可。