iosobjective-cabpersonviewcontrollerabrecordref

How to display phone numbers and email and names of a user?


This is what I have tried:

-(void) vDisplayPerson:(ABRecordRef)person
{
    ABPersonViewController *picker = [[ABPersonViewController alloc] init] ;
    picker.personViewDelegate = self;
    picker.displayedPerson = person;
    picker.displayedProperties=@[@(kABPersonPhoneProperty),@(kABPersonEmailProperty),@(kABPersonBirthdayProperty),@(kABPersonOrganizationProperty),@(kABPersonJobTitleProperty),@(kABPersonDepartmentProperty),@(kABPersonNoteProperty),@(kABPersonCreationDateProperty)];
    // Allow users to edit the person’s information
    picker.allowsEditing = YES;
    [self.navigationController pushViewController:picker animated:YES];

}

Notice I have set up displayedProperties to include many things. Phone. Person. Birthday. Yet, only name and job title shows up.

I want to display the same kind of information people use to see in contact. Is it no longer possible in iOs6?

Update: I strongly suspected that the issue is not in the display but the fact that for some reason the whole person record simply does not contain phone number. That is because I can edit the contact, add phone number and phone number will be seen. However, the update is not propagated to the "real" contact. The update made on my program does not propagate to the real contact. Update make on the real contact does not show on my program.

I am using CFArrayRef refAllPeople = ABAddressBookCopyArrayOfAllPeople( addressBook );

This is in iPhone 5.1 simulator by the way.


Solution

  • The key here is that reference to the result of ABAddressBookCreate must not be released yet. So I created a property @property (nonatomic) ABAddressBookRef addressBook; and release it only latter at dealloc (which will not be called till the end of the program).

    This fix the issue.