2012-10-07 23 views
1

我想知道默認情況下iPhone地址簿中的完整「人員記錄」屬性。Iphone AddressBook Framework - 人員屬性

必須的API

https://developer.apple.com/library/content/documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Introduction.html#//apple_ref/doc/uid/TP40007744

https://developer.apple.com/documentation/addressbook#//apple_ref/doc/uid/TP40007210

在什麼地方隱藏的,但我沒有找到一個列表爲止。

有沒有人的屬性的列表:名稱,女士prename,電子郵件,電話和可能的 「隱性」 像輸入字段創建

+0

列表位於https://developer.apple.com/documentation/addressbook/address_book_objective_c_constants/default_person_properties –

回答

2
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 

ABAddressBookRef addressBook = ABAddressBookCreate(); 

NSArray *array= (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook); 

for (id persion in array) 
{ 
    ABRecordRef record = (ABRecordRef)persion; 

    NSString* firstName=(NSString *)ABRecordCopyValue(record, kABPersonFirstNameProperty); 
    NSString* lastName=(NSString *)ABRecordCopyValue(record, kABPersonLastNameProperty); 

    //do something 

    [firstName release]; 
    [lastName release]; 


    ABMultiValueRef mulPhone = (ABMultiValueRef) ABRecordCopyValue(record, kABPersonPhoneProperty) ; 
    int count = ABMultiValueGetCount(mulPhone); 
    for(CFIndex i=0 ; i < count ; i++) 
    { 
     NSString* phoneLabel = (NSString*) ABMultiValueCopyLabelAtIndex(mulPhone, i) ;   
     NSString* cellPhone =(NSString*) ABMultiValueCopyValueAtIndex(mulPhone, i) ; 

     //do something 

     [phoneLabel release] ; 
     [cellPhone release]; 
    } 
    CFRelease(mulPhone) ; 


    ABMultiValueRef mulAddress =(ABMultiValueRef) ABRecordCopyValue(record, kABPersonAddressProperty) ; 
    count = ABMultiValueGetCount(mulAddress); 
    for(CFIndex i=0 ; i< count ; i++) 
    { 
     NSString* addressLabel = (NSString*) ABMultiValueCopyLabelAtIndex(mulAddress, i) ; 

     CFDictionaryRef dict = (CFDictionaryRef)ABMultiValueCopyValueAtIndex(mulAddress, i); 

     NSString* homeStreet = (NSString*)CFDictionaryGetValue(dict, kABPersonAddressStreetKey); 
     NSString* homeCity = (NSString*)CFDictionaryGetValue(dict, kABPersonAddressCityKey); 
     NSString* homeCountry = (NSString*)CFDictionaryGetValue(dict, kABPersonAddressCountryKey); 

     //do something 
     CFRelease(dict) ; 

     [addressLabel release]; 
    } 
    CFRelease(mulAddress) ; 



    NSString* company = (NSString*)ABRecordCopyValue(record, kABPersonOrganizationProperty); 
    if (company) { 
//do something 
    } 
    [company release]; 



    ABMultiValueRef mulEmail = (ABMultiValueRef)ABRecordCopyValue(record, kABPersonEmailProperty) ; 
    count = ABMultiValueGetCount(mulEmail); 
    for(CFIndex i=0 ; i< count; i++) 
    { 
     NSString* emailLabel = (NSString*)ABMultiValueCopyLabelAtIndex(mulEmail, i) ; 
     NSString* email = (NSString*) ABMultiValueCopyValueAtIndex(mulEmail, i) ; 

     //do something 
     [emailLabel release]; 
     [email release]; 


    } 
    CFRelease(mulEmail) ; 


} 
[array release]; 
CFRelease(addressBook); 


[pool release]; 
+0

thx,是否沒有像創建條目時的時間這樣的屬性? – Dukeatcoding

+0

請參閱ABPerson的kABPersonCreationDateProperty &kABPersonModificationDateProperty –

+0

此答案中使用的許多密鑰在啓動iOS 10時不再存在。 –

0

的人默認屬性:https://developer.apple.com/documentation/addressbook/address_book_objective_c_constants/default_person_properties

kABFirstNameProperty:名字。

kABLastNameProperty:姓氏。

kABFirstNamePhoneticProperty:第一個名字的語音表示。

kABLastNamePhoneticProperty:姓氏的語音表示。

kABNicknameProperty:暱稱。

kABMaidenNameProperty:婚前姓名。

kABBirthdayProperty:出生日期。

kABBirthdayComponentsProperty:出生日期作爲日期組件。

kABOrganizationProperty:公司名稱。

kABJobTitleProperty:職稱。

kABHomePageProperty:主頁網頁。

kABURLsProperty:網頁。

kABCalendarURIsProperty:日曆URI。

kABEmailProperty:電子郵件地址。

kABAddressProperty:街道地址。

kABOtherDatesProperty:與某人關聯的日期。

kABOtherDateComponentsProperty:與某人關聯的日期,作爲日期組件。

kABRelatedNamesProperty:與人相關的人的姓名。

kABDepartmentProperty:部門名稱。

kABPersonFlags:指定地址簿應用程序中記錄的名稱排序和配置的屬性。見Person Flags

kABPhoneProperty:普通電話號碼。

kABInstantMessageProperty:即時消息ID。

kABNoteProperty:註釋。

kABSocialProfileProperty:社交網絡配置文件。

kABMiddleNameProperty:中間名。

kABMiddleNamePhoneticProperty:中間名的拼音表示。

kABTitleProperty:標題,如「先生」,「太太」,「一般」,「紅衣主教」或「主」

kABSuffixProperty:後綴,如「老「,‘小’,‘三’或‘彼岸’

並因爲人是一個記錄,它也有:。https://developer.apple.com/documentation/addressbook/address_book_objective_c_constants/default_record_properties

kABUIDProperty:此記錄的唯一ID。無論記錄有多大改變,它都保證永遠不會改變。如果您需要存儲對記錄的引用,請使用此值。

kABCreationDateProperty:記錄第一次保存的日期。

kABModificationDateProperty:記錄上次保存的日期。

請注意,properties()應該返回給您一個人的所有屬性列表。