1
votes

I am trying to find out which attributes a complete "Person Record" in the iPhone Addressbook has by default.

It must be hidden somewhere in the 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

but I didn't find a list so far.

Has anybody a list of the attributes: Name, Prename, email, tel and possible "hidden" field like entry created

2

2 Answers

2
votes
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
votes

Default attributes for a Person: https://developer.apple.com/documentation/addressbook/address_book_objective_c_constants/default_person_properties

kABFirstNameProperty: First name.

kABLastNameProperty: Last name.

kABFirstNamePhoneticProperty: Phonetic representation of the first name.

kABLastNamePhoneticProperty: Phonetic representation of the last name.

kABNicknameProperty: Nickname.

kABMaidenNameProperty: Maiden name.

kABBirthdayProperty: Birth date.

kABBirthdayComponentsProperty: Birth date as date components.

kABOrganizationProperty: Company name.

kABJobTitleProperty: Job title.

kABHomePageProperty: Home web page.

kABURLsProperty: Web pages.

kABCalendarURIsProperty: Calendar URIs.

kABEmailProperty: Email addresses.

kABAddressProperty: Street addresses.

kABOtherDatesProperty: Dates associated with a person.

kABOtherDateComponentsProperty: Dates associated with a person, as date components.

kABRelatedNamesProperty: Names of people related to a person.

kABDepartmentProperty: Department name.

kABPersonFlags: Property that specifies the name ordering and configuration of a record in the Address Book application. See Person Flags.

kABPhoneProperty: Generic phone number.

kABInstantMessageProperty: Instant messaging ID.

kABNoteProperty: Notes.

kABSocialProfileProperty: Social network profile.

kABMiddleNameProperty: Middle name.

kABMiddleNamePhoneticProperty: Phonetic representation of the middle name.

kABTitleProperty: Title, such as “Mr.,” “Mrs.,” “General,” “Cardinal,” or “Lord.”

kABSuffixProperty: Suffix, such as “Sr.,” “Jr.,” “III.,” or “Esq.”

And because a Person is a Record, it also has: https://developer.apple.com/documentation/addressbook/address_book_objective_c_constants/default_record_properties

kABUIDProperty: The unique ID for this record. It’s guaranteed never to change, no matter how much the record changes. If you need to store a reference to a record, use this value.

kABCreationDateProperty: The date when the record was first saved.

kABModificationDateProperty: The date when the record was last saved.

Note, the properties() should return you the list of all properties of a Person.