views:

259

answers:

1

I am having some trouble accessing the iphone addressbook given a ABReferenceID.

The method is being called correctly (accessoryButtonTappedForRowWithIndexPath), all the #import stuff is fine (as I can save the data no problem).

I have a contact with ReferenceID = 69273024, I simply want to bring 'him up.

I am trying to do this with the following technique, but line 2 is wrong. I can't work out how to correctly integrate the number into the problem. Any tips?

ABPersonViewController *pvc = [[ABPersonViewController alloc] init];
pvc.displayedPerson = 69273024;

[[self navigationController] pushViewController:pvc animated:YES];  

Regards, norskben.

+1  A: 

The displayedPerson property should be set to an ABRecordRef. You can get the ABRecordRef from the ABRecordID using ABAddressBookGetPersonWithRecordID. You can get the ABAddressBookRef using ABAddressBookCreate.

UPDATE
Here is example code, but I haven't tested it:

ABPersonViewController *pvc = [[ABPersonViewController alloc] init];
pvc.displayedPerson = ABAddressBookGetPersonWithRecordID(ABAddressBookCreate(),69273024);

[[self navigationController] pushViewController:pvc animated:YES];
[pvc release];
gerry3
@gerry3 and others, can you dig up a code example?
norskben
I threw the suggested code together in an update to the answer. Let me know if you find any issues.
gerry3
yeah it helps, its close to what i now have, except now I'm not 100% sure i'm sending it the right number in the first place. Because I keep getting an empty contact view.How can I ensure I have a good number to test with, which works with the above code you sent?
norskben
i just did further tests, and it seems that pvc.displayedPerson is being set to 0/null, when I call it as an integer/string.The NSlog data i get is SQL[19460:207] Record ID - 69284016; [19460:207] pvc.displayedPerson - (null)on code: NSLog(@"Record ID - %d", recordId); NSLog(@"pvc.displayedPerson - %@", pvc.displayedPerson);
norskben
i posted my full problem onto: http://stackoverflow.com/questions/2138923/iphone-addressbook-getting-null-item-in-abaddressbookgetpersonwithrecordid
norskben