以下を使用して名前アドレスなどを連絡先に保存するとエラーが発生します
IBAction:
ABUnknownPersonViewController *unknownPersonViewController = [[ABUnknownPersonViewController alloc] init];
unknownPersonViewController.displayedPerson = (ABRecordRef)[self buildContactDetails];
unknownPersonViewController.allowsAddingToAddressBook = YES;
[self.navigationController pushViewController:unknownPersonViewController animated:YES];
}
- (ABRecordRef)buildContactDetails {
NSLog(@"building contact details");
ABRecordRef person = ABPersonCreate();
CFErrorRef error = NULL;
// firstname
ABRecordSetValue(person, kABPersonFirstNameProperty, @"Don Juan", NULL);
// email
ABMutableMultiValueRef email = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMultiValueAddValueAndLabel(email, @"myemail.hotmail.com", CFSTR("email"), NULL);
ABRecordSetValue(person, kABPersonEmailProperty, email, &error);
CFRelease(email);
// Start of Address
ABMutableMultiValueRef address = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
NSMutableDictionary *addressDict = [[NSMutableDictionary alloc] init];
[addressDict setObject:@"Hig Street" forKey:(NSString *)kABPersonAddressStreetKey];
[addressDict setObject:@"WR11" forKey:(NSString *)kABPersonAddressZIPKey];
[addressDict setObject:@"Evesham" forKey:(NSString *)kABPersonAddressCityKey];
ABMultiValueAddValueAndLabel(address, addressDict, kABWorkLabel, NULL);
ABRecordSetValue(person, kABPersonAddressProperty, address, &error);
// End of Address
if (error != NULL)
NSLog(@"Error: %@", error);
return person;
次の行でエラーが発生します:
ABMultiValueAddValueAndLabel(address, addressDict, kABWorkLabel, NULL);
具体的addressDict
には、
"Implicit conversion of the Objective-C pointer ARC error requires a bridged cast"
だから私は試しました:
ABMultiValueAddValueAndLabel(address, (__bridge_retained CFDataRef)dataRef, kABWorkLabel, NULL);
今、アイデアがなくなった