2

Has anyone had issues with this code...

ABRecordRef person = ABAddressBookGetPersonWithRecordID (addressBook,recordID);

I have had major issues with this so far. I have previously posted this question Intermittent error accessing core data model / contacts database

However, I have now tracked it down to this method returning a NULL value despite there being legitimate addressBook and recordID values.

Any idea of why this might be happening?

Many thanks

Community
  • 1
  • 1
Ben Thompson
  • 4,743
  • 7
  • 35
  • 52

2 Answers2

1

Posting answer in case it helps others...

It turns out the issue was memory related. I have created an addressBook with: ABAddressBookCreate(). This was happening inside a loop so was being created over and over again. The solution was to move the creation outside of the loop and balance with CFRelease(addressBook); command.

Hope this helps others!!

Ben Thompson
  • 4,743
  • 7
  • 35
  • 52
0

I have successfully done a addressbook with add,edit and delete the record from the contact list.there is no such type of error comes. put this in .h file...

ABRecordID 
recordID;

put following code in the

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
{
 recordID = ABRecordGetRecordID(person);
 NSLog(@"Record id is %d",recordID);
}

if You getting the reoord id in that then i think there would be no such problem occours. Lets try ...

Bhavin_m
  • 2,746
  • 3
  • 30
  • 49
Tarun
  • 102
  • 7