读书人

地址簿(Address Book)运用例子

发布时间: 2012-09-19 13:43:53 作者: rapoo

地址簿(Address Book)使用例子

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 NumberCFRelease(phoneNumber);}}CFRelease(phoneNumbers);}CFRelease(peopleWithName);CFRelease(addressBook);
?

读书人网 >移动开发

热点推荐