Skip to content

Instantly share code, notes, and snippets.

@aquarla
Created October 5, 2010 07:39
Show Gist options
  • Save aquarla/611180 to your computer and use it in GitHub Desktop.
Save aquarla/611180 to your computer and use it in GitHub Desktop.
iPhoneのアドレス帳から電話番号を取り出すサンプルコード
#import <AddressBook/AddressBook.h>
//...
NSString *title = @"";
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef people = ABAddressBookCopyPeopleWithName(addressBook, CFSTR("ほげほげ"));
if (CFArrayGetCount(people) > 0) {
ABRecordRef recordRef = (ABRecordRef)CFArrayGetValueAtIndex(people, 0);
ABMultiValueRef phones = ABRecordCopyValue(recordRef, kABPersonPhoneProperty);
if (ABMultiValueGetCount(phones) > 0) {
title = (NSString *)ABMultiValueCopyValueAtIndex(phones, 0);
}
CFRelease(phones);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment