我试图找出 iPhone 地址簿中完整的“个人记录”默认具有哪些属性。
它必须隐藏在 API 中的某个位置
https://developer.apple.com/documentation/addressbook#//apple_ref/doc/uid/TP40007210
但到目前为止我还没有找到一份清单。
有任何人的属性列表:姓名、名字、电子邮件、电话和可能的“隐藏”字段,如创建的条目
我试图找出 iPhone 地址簿中完整的“个人记录”默认具有哪些属性。
它必须隐藏在 API 中的某个位置
https://developer.apple.com/documentation/addressbook#//apple_ref/doc/uid/TP40007210
但到目前为止我还没有找到一份清单。
有任何人的属性列表:姓名、名字、电子邮件、电话和可能的“隐藏”字段,如创建的条目
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];
Person 的默认属性: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:指定地址簿应用程序中记录的名称排序和配置的属性。请参阅人员标志。
kABhoneProperty:通用电话号码。
kABInstantMessageProperty:即时消息 ID。
kABNoteProperty:注释。
kABSocialProfileProperty:社交网络配置文件。
kABMiddleNameProperty:中间名。
kABMiddleNamePhoneticProperty:中间名的语音表示。
kABTitleProperty : 头衔,例如“先生”、“夫人”、“将军”、“红衣主教”或“勋爵”。</p>
kABSuffixProperty:后缀,例如“Sr.”、“Jr.”、“III.”或“Esq.”</p>
而且因为一个人是一个记录,它也有:https ://developer.apple.com/documentation/addressbook/address_book_objective_c_constants/default_record_properties
kABUIDProperty:此记录的唯一 ID。无论记录发生多大变化,它都保证永远不会改变。如果您需要存储对记录的引用,请使用此值。
kABCreationDateProperty:首次保存记录的日期。
kABModificationDateProperty:上次保存记录的日期。
注意,properties()应该返回一个人的所有属性的列表。