Sort NSArray of custom objects by their NSDate properties

后端 未结 5 1239
执笔经年
执笔经年 2020-11-30 06:20

I am attempting to sort an NSArray that is populated with custom objects. Each object has a property startDateTime that is of type NSDate.

The followin

5条回答
  •  一生所求
    2020-11-30 06:50

    You can achieve this like this,

    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:FALSE];
    
    [self.Array sortUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
    

提交回复
热议问题