To show the list of contact in iPhone use the code Below:
1- import the ContactsUI framwork in viewController
2- Confrom the ViewController to the CNContactPickerDelegate 
3- call the delegate method func contactPicker(picker: CNContactPickerViewController, didSelectContacts contacts: [CNContact])
import AddressBook
import ContactsUI
class ViewController: UIViewController, CNContactPickerDelegate  
@IBAction func showContactList(sender:UIButton)
    {
            let cnPicker = CNContactPickerViewController()
            cnPicker.delegate = self
            self.presentViewController(cnPicker, animated: true, completion: nil)
    }
func contactPicker(picker: CNContactPickerViewController, didSelectContacts contacts: [CNContact])
    {
        contacts.forEach { contact in
            for number in contact.phoneNumbers {
                let phoneNumber = number.value as! CNPhoneNumber
               print("number is = \(phoneNumber)")
            }
        }
    }
                       
                    
0 Comment(s)