我想添加一個地址到採摘接觸:不能地址保存到ABRecordRef
- (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);
}
正如我在控制檯中看到,有一個與保存它沒有問題。但是,當我在聯繫人應用程序中打開聯繫人時,沒有保存的地址。