How to get user sort order with CNContact API

I know that I can sort with CNContacts as follows:

let fetch = CNContactFetchRequest(...) fetch.sortOrder = .UserDefault 

Question: how can I find what sort order is? In addition to some hacker heuristic studying what comes back from the enumeration to choose from.

There is an old call to ABPersonGetSortOrdering (), which is likely to remain for a while, but there is certainly a CNContact way.

+8
source share
2 answers

ABPersonGetSortOrdering() deprecated in iOS 9.0: use [[CNContactsUserDefaults sharedDefaults] sortOrder]

let sortOrder = CNContactsUserDefaults.sharedDefaults (). sortOrder

+10
source

Swift 4

Using the default sort order:

 let sortOrder = CNContactsUserDefaults.shared().sortOrder 

For custom sort order, i.e.

 let customSortOrder = CNContactSortOrder.givenName 
+3
source

Source: https://habr.com/ru/post/1233744/


All Articles