ABAddressBookRef addressBook = ABAddressBookCreate(); CFArrayRef peopleWithName = ABAddressBookCopyPeopleWithName (addressBook, (CFStringRef)@"name"); if((int)CFArrayGetCount(peopleWithName)){ CFIndex theIndex= 0; ABRecordRef personRecord = CFArrayGetValueAtIndex(peopleWithName, theIndex); //kABPersonPhoneProperty to get phone number //ABMultiValueRef eMails= ABRecordCopyValue(personRecord,kABPersonEmailProperty); ABMultiValueRef phoneNumbers= ABRecordCopyValue(personRecord, kABPersonPhoneProperty); if(ABMultiValueGetCount(phoneNumbers)){ CFStringRef phoneNumber = ABMultiValueCopyValueAtIndex(phoneNumbers, 0); if(phoneNumber!=nil){ //TODO:to save the phone number //release the Phone Number CFRelease(phoneNumber); } } CFRelease(phoneNumbers); } CFRelease(peopleWithName); CFRelease(addressBook);
地址簿(Address Book)使用例子
最新推荐文章于 2023-07-01 11:37:23 发布