How to query IOS Contacts Contacts Display order settings using New Contact Framework

Viewed 1283

I am developing an app where I am showing some contacts from the server and currently i am sorting the contacts from the server but now i want to read the contact setting from IOS ->Settings ->Contacts ->Display Order using the new Contact framework , I do not see any api to query system settings directly without creating any contact object which I do not want to do I just want to query system settings without creating any contact object.

Im able to query sort settings using below code but there is no equivlent for display order

let sortContact = CNContactsUserDefaults.sharedDefaults().sortOrder
3 Answers

If it's just for displaying the name you can use the PersonNameComponentsFormatter:

var nameComponents = PersonNameComponents()
nameComponents.givenName = "Mihai"
nameComponents.lastName = "Radu"
print(PersonNameComponentsFormatter.localizedString(from: nameComponents, style: .default, options: []))

According to the docs this takes into account the name order rules for the current locale but allows user preferences to override it.

Related