按NSDictionary的key来对其进行排序:
先将dict的allkeys赋给一个数组,然后通过sortedArrayUsingComparator:方法对数组排序,然后遍历数组取字典对应key的值就ok
int i = 0;
NSArray *keys = [dict allKeys];
NSArray *sortedArray = [keys sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
return [obj1 compare:obj2 options:NSNumericSearch];
}];
for (NSString *categoryId in sortedArray) {
⋯⋯
NSLog(@"[dict objectForKey:categoryId] === %@",[dictobjectForKey:categoryId]);
}