Grouping of Custom Objects in Objective-C

前端 未结 6 1600
伪装坚强ぢ
伪装坚强ぢ 2021-01-12 03:59

I have and array of custom objects of Person Class

Person : NSObject{
    NSString *firstName;
    NSString *lastName; 
    NSString *age;
}

NSMutableArray          


        
6条回答
  •  北海茫月
    2021-01-12 04:49

    You can try this is custom object sorting for an array

    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"Firstname" ascending:NO selector:@selector(compare:)];
    
    [Array sortUsingDescriptors:[NSArray arrayWithObjects:sortDescriptor, nil]];
    

提交回复
热议问题