0
func fetchContacts(){

    let key = [CNContactGivenNameKey, CNContactPhoneNumbersKey] as [CNKeyDescriptor]
    let request = CNContactFetchRequest(keysToFetch: key)
    try! contactStore.enumerateContacts(with: request) { (contact, stoppingPointer) in

        let name = contact.givenName
        let number = contact.phoneNumbers.first?.value.stringValue


        let contactToAppend = ContactStruct(name: name, number: number)
        self.contacts.append(contactToAppend)

        self.queryPhoneNumber()

    }
    tableView.reloadData()
}

In this way I'm getting contact numbers(with country code) and names of the contacts. How to get the contacts without country code.please help me in solving this problem. Thank you.

Sri Vathsav
  • 91
  • 1
  • 1
  • 3
  • 1
    Related: https://stackoverflow.com/q/34730543/3151675 – Tamás Sengel Jan 31 '18 at 09:45
  • Hello, tanks for reply... but only space between countryCode and phoneNumber has be cleared but (+91) is my countryCode it didn't cleared.Please help me in solving this. and one more thing only our country is going to to user this so is there any option like if the number is starting with "+91" then remove it. If yes please help me. THANKYOU – Sri Vathsav Jan 31 '18 at 10:04

0 Answers0