Advertisement
Guest User

Untitled

a guest
May 6th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. NSArray *sortedArray = [drinkDetails sortedArrayUsingSelector:@selector(???)];
  2.  
  3. - (NSComparisonResult)compare:(Person *)otherObject {
  4. return [self.birthDate compare:otherObject.birthDate];
  5. }
  6.  
  7. NSArray *sortedArray = [drinkDetails sortedArrayUsingSelector:@selector(compare:)];
  8.  
  9. NSSortDescriptor *sortDescriptor;
  10. sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"birthDate"
  11. ascending:YES];
  12. NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
  13. NSArray *sortedArray = [drinkDetails sortedArrayUsingDescriptors:sortDescriptors];
  14.  
  15. NSArray *sortedArray;
  16. sortedArray = [drinkDetails sortedArrayUsingComparator:^NSComparisonResult(id a, id b) {
  17. NSDate *first = [(Person*)a birthDate];
  18. NSDate *second = [(Person*)b birthDate];
  19. return [first compare:second];
  20. }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement