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

后端 未结 10 1787
执念已碎
执念已碎 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 14:06

    Swift 3 "_$!!$_" This item is written to create difference as well as putting a piece of opportunity to rely on various options.

    for con in contacts
    {
        for num in con.phoneNumbers
        {
            if num.label == "_$!!$_"    //Please Don't Change this!
            {
                self.contactNames.append(con.givenName)
                self.contactNums.append(num.value.stringValue)
                break
            }
            else
            {
                continue
            }
        }
    }
    

    Here we have num.value.stringValue

提交回复
热议问题