CNContactPicker - Swift Version
Sample Code :
https://github.com/imayaselvan/CNContact-Example
Sample code for geting the specific contact :
let predicate = CNContact.predicateForContactsMatchingName("Appleseed")
let keysToFetch = [CNContactGivenNameKey, CNContactFamilyNameKey]
let store = CNContactStore()
let contacts = try store.unifiedContactsMatchingPredicate(predicate,
keysToFetch: keysToFetch)
for contact in contacts {
print("\(contact.givenName) \(contact.familyName)")
}
For creating New Contact :
let imay = CNMutableContact()
imay.givenName = "imay"
imay.familyName = "Selvan"
let saveRequest = CNSaveRequest()
saveRequest.addContact(john, toContainerWithIdentifier: nil)
try store.executeSaveRequest(saveRequest)