1

I'm trying to implement some code that writes to a contact using code from this Address Book guide. I've declared a property in my ViewController.h:

@property ABRecordRef mABRecordRef;

Then I retrieve a record:

- (BOOL)peoplePickerNavigationController:
      (ABPeoplePickerNavigationController *)peoplePicker
      shouldContinueAfterSelectingPerson:(ABRecordRef)person {

At this point, I am able to successfully call ABRecordSetValue:

CFErrorRef anError = NULL;
bool didSet;   
didSet = ABRecordSetValue(person, kABPersonFirstNameProperty, (CFStringRef)@"foo", &anError);
if( didSet )
{
    // ...

In this method, I also save the record:

self.mABRecordRef = person;

After some user action (in another method), I attempt to use this record in the same way:

CFErrorRef anError = NULL;
bool didSet;
didSet = ABRecordSetValue(self.ABRecordRef, kABPersonFirstNameProperty, (CFStringRef)@"foo", &anError);

But I get an error:

EXC_BAD_ACCESS(code=2, address=0x...

Why is this? I am assuming (perhaps incorrectly) that my ABRecordRef isn't released between my first and second uses.

I've also tried saving off that record's UniqueId as well as peoplePicker.addressBook, then later on pulling the same record back, but I get a similar error.

turtle
  • 928
  • 1
  • 11
  • 23
user655321
  • 1,572
  • 2
  • 16
  • 33

0 Answers0