Last active
April 5, 2019 06:07
-
-
Save hngfu/23fa7e4405b0810efd42b86957c8a515 to your computer and use it in GitHub Desktop.
다양한 조건을 걸어서 정렬하는 방법!
This file contains 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
let familyNameSortDescriptor = NSSortDescriptor(key: CNContact.familyNameSortKey, ascending: true, selector: #selector(NSString.localizedStandardCompare(_:))) | |
let givenNameSortDescriptor = NSSortDescriptor(key: CNContact.givenNameSortKey, ascending: true, selector: #selector(NSString.localizedStandardCompare(_:))) | |
let sortDescriptors = [familyNameSortDescriptor, givenNameSortDescriptor] | |
let sortedContacts = (contacts as NSArray).sortedArray(using: sortDescriptors) | |
guard let contacts = sortedContacts as? [CNContact] else { return } | |
self.contacts = contacts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment