Swift2 如何在ios 9中检索联系人号码
在ios 8中,我使用以下代码打印用户的联系电话Swift2 如何在ios 9中检索联系人号码,swift2,ios9,xcode7,Swift2,Ios9,Xcode7,在ios 8中,我使用以下代码打印用户的联系电话 if let contacts = ABAddressBookCopyArrayOfAllPeople(self.addressBookRef)?.takeRetainedValue() as? NSArray { for record:ABRecordRef in contacts { let phones:ABMultiValueRef = ABRecordCopyValue(reco
if let contacts = ABAddressBookCopyArrayOfAllPeople(self.addressBookRef)?.takeRetainedValue() as? NSArray {
for record:ABRecordRef in contacts {
let phones:ABMultiValueRef = ABRecordCopyValue(record, kABPersonPhoneProperty).takeUnretainedValue() as ABMultiValueRef
for(var numberIndex : CFIndex = 0; numberIndex < ABMultiValueGetCount(phones); numberIndex++)
{
let phoneUnmaganed = ABMultiValueCopyValueAtIndex(phones, numberIndex)
let phoneNumber : String = phoneUnmaganed.takeUnretainedValue() as! String
这应该可以做到
if (contact.isKeyAvailable(CNContactPhoneNumbersKey)) {
for phoneNumber:CNLabeledValue in contact.phoneNumbers {
let a = phoneNumber.value as! CNPhoneNumber
print("\(a.stringValue)")
}
}
印刷品的风格
(555)766-4823请帮我检索所有联系电话,store.unifiedContactsMatchingPredicate(CNContact.predicateForContactsMatchingName(“Siva”),我只想获取所有联系人。但这行代码只帮助我们获取Siva的联系详细信息。你有什么建议吗?提前谢谢
if (contact.isKeyAvailable(CNContactPhoneNumbersKey)) {
for phoneNumber:CNLabeledValue in contact.phoneNumbers {
let a = phoneNumber.value as! CNPhoneNumber
print("\(a.stringValue)")
}
}