How to get a CNContact phone number(s) as string in Swift?

后端 未结 10 1804
执念已碎
执念已碎 2020-12-13 13:31

I am attempting to retrieve the names and phone number(s) of all contacts and put them into arrays with Swift in iOS. I have made it this far:



        
10条回答
  •  渐次进展
    2020-12-13 13:56

    In swift 3 you can get direclty

     if item.isKeyAvailable(CNContactPhoneNumbersKey){
            let phoneNOs=item.phoneNumbers
            let phNo:String
            for item in phoneNOs{
                print("Phone Nos \(item.value.stringValue)")
            }
    

提交回复
热议问题