NSdictionary如何排序

先将字典的key值取出放在一个数组中,将key值数组排序,然后按个取出遍历

 NSArray *keyArray = appListDic.allKeys;

  NSArray *stortArray = [keyArray sortedArrayUsingComparator:^NSComparisonResult(id  _Nonnull obj1, id  _Nonnull obj2) {
                return [obj1 compare:obj2 options:NSNumericSearch];
            }];


 for (NSString *key in stortArray) {
                NSDictionary *dict =  appListDic[key];
             
            }


你可能感兴趣的:(Object-C)