0

I'm trying to add an address to picked contact:

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
                         didSelectPerson:(ABRecordRef)person{

    // Adding address
    ABMutableMultiValueRef addressMultipleValue = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
    NSMutableDictionary *addressDictionary = [[NSMutableDictionary alloc] init];
    [addressDictionary setObject:@"8-15 Dereham Place" forKey:(NSString *)kABPersonAddressStreetKey];
    [addressDictionary setObject:@"London" forKey:(NSString *)kABPersonAddressCityKey];
    [addressDictionary setObject:@"EC2A 3HJ" forKey:(NSString *)kABPersonAddressZIPKey];
    [addressDictionary setObject:@"United Kingdom" forKey:(NSString *)kABPersonAddressCountryKey];
    [addressDictionary setObject:@"gb" forKey:(NSString *)kABPersonAddressCountryCodeKey];

    ABMultiValueAddValueAndLabel(addressMultipleValue, (__bridge CFTypeRef)(addressDictionary), kABHomeLabel, NULL);

    ABRecordSetValue(person, kABPersonAddressProperty, addressMultipleValue, nil);
    CFErrorRef anError = NULL;
    BOOL didSet;

    didSet = ABAddressBookSave(_addressBook, NULL);
    if (!didSet) {
        NSError *er = (__bridge NSError *)(anError);
        NSLog(@"Error saving record: %@", er.localizedDescription);}else{
            NSLog(@"Record updated successfully");
        }
    CFRelease(addressMultipleValue);
}

As I see in console, there is no problem with saving it. However, when I open contact in Contacts App there is no saved address.

Shmidt
  • 16,436
  • 18
  • 88
  • 136

2 Answers2

2

The release notes are REALLY helpful. Neither item referenced: "ABPeoplePickerNavigationController.h" or the new "PeoplePicker: Picking a Person or Property sample project" can be found.

Apple's "enhancement" has hosed 20 business apps of mine that rely on AB for contact info. Thanks again Apple for fixing something that wasn't broke.

John
  • 538
  • 4
  • 18
0

Citing from iOS 8 Release Notes document:

The Address Book UI people picker has been changed for iOS 8. A new mode with new API has been added where the app does not need access to the user’s contacts and the user will not be prompted for access. A temporary copy of the selected person is returned to the app. See ABPeoplePickerNavigationController.h for more details.

See the new PeoplePicker: Picking a Person or Property sample project demonstrating usage of the new mode.

So you gonna meet the new API, until that, you're probably working just with temporary copies rather than actual database, that actually Contacts app accesses.

Community
  • 1
  • 1
lef
  • 1,196
  • 1
  • 9
  • 18