Created
June 28, 2016 23:20
-
-
Save erickva/11557eb8ff315c32256142c637bc0c9f to your computer and use it in GitHub Desktop.
Delete Duplicates and Sort Array of Objects in Objective-C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSOrderedSet *orderedSet = [NSOrderedSet orderedSetWithArray:_lastMessages]; | |
NSArray *arrayWithoutDuplicates = [orderedSet array]; | |
NSSortDescriptor *dateDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"date_" ascending:YES]; | |
NSArray *sortDescriptors = [NSArray arrayWithObject:dateDescriptor]; | |
NSArray *sortedEventArray = [arrayWithoutDuplicates sortedArrayUsingDescriptors:sortDescriptors]; | |
_lastMessages = [sortedEventArray mutableCopy]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment