Sorting NSString values as if NSInteger using NSSortDescriptor

前端 未结 7 1635
执念已碎
执念已碎 2020-11-28 09:10

I have created a sort descriptor to sort a plist response coming from my server. This works well with sort key having values upto 9. With more than 10 items I see abrupt res

7条回答
  •  佛祖请我去吃肉
    2020-11-28 09:51

    NSSortDescriptor *aSortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"sort.intValue" ascending:YES];
    self.myList = [NSMutableArray arrayWithArray:[unsortedList sortedArrayUsingDescriptors:[NSArray arrayWithObject:aSortDescriptor]]];
    

    Sort based on the value of the integer.

提交回复
热议问题