0

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.

user4951
  • 32,206
  • 53
  • 172
  • 282
  • I am NOT trying to get the email addresses and phone numbers. I just want to display it using ABPersonViewController. – user4951 Mar 29 '13 at 07:56
  • 1
    I bet this has to do with the new permission system. You need to request access to the contact database as of iOS 6.0, but I'm not sure if it applies in this case or not... – borrrden Mar 29 '13 at 08:01
  • It doesn't work in ios 5.1 simulator too. – user4951 Mar 29 '13 at 08:14
  • It seems like you are saving the changes to a *copy* of the database instead of the database itself. Try using `ABAddressBookCreate()` instead. – borrrden Mar 29 '13 at 08:34
  • I did but the addressbook has been released a long time ago. What about if I want to use the same database rather than the copy databases? – user4951 Mar 29 '13 at 08:40
  • I don't understand what you are saying. The above method (while strangely named) will create a database *with the contents of your contacts DB* as per the documentation. So you should edit this object, and then call save on it. – borrrden Mar 29 '13 at 08:41
  • I am not interested in updating the database. I am interested in displaying existing phones. – user4951 Mar 29 '13 at 08:42
  • Your question indicates that the contact doesn't have a phone number... – borrrden Mar 29 '13 at 08:45

1 Answers1

0

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.

user4951
  • 32,206
  • 53
  • 172
  • 282