iOS 9: get CNContact country code and phone number

后端 未结 5 1258
-上瘾入骨i
-上瘾入骨i 2020-12-09 10:42

I want to get the country code and phone number from CNContact on iOS 9. I tried many things but couldn\'t find a way. The best result I achieved is printing:



        
5条回答
  •  心在旅途
    2020-12-09 11:16

    They two members can be accessed via valueForKey:

    let countryCode = number.valueForKey("countryCode") as? String
    let digits = number.valueForKey("digits") as? String
    

    Please note that due to the fact that these two fields are part of a private API, there's no guarantee that in the future versions of the Contacts framework they won't be removed/replaced.

提交回复
热议问题