アプリ ドキュメント ディレクトリの vcf ファイルから vcard データを文字列に取得しています。文字列は問題ありませんが、 ABPersonCreatePeopleInSourceWithVCardRepresentation
BAD_ACCESS エラーがスローされます。コードはこちら...
ABRecordRef defaultSource = ABAddressBookCopyDefaultSource(addressBook);
NSData *data=[vcardString dataUsingEncoding:NSUTF8StringEncoding];
CFDataRef vCardData = (__bridge CFDataRef)data;
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
if(granted)
{
NSLog(@"%@",vcardString);
CFArrayRef vCardPeople = ABPersonCreatePeopleInSourceWithVCardRepresentation(defaultSource, vCardData);//BAD_ACCESS ERROR
for (CFIndex index = 0; index < CFArrayGetCount(vCardPeople); index++) {
ABRecordRef person = CFArrayGetValueAtIndex(vCardPeople, index);
ABAddressBookAddRecord(addressBook, person, NULL);
NSLog(@"added");
}
CFRelease(vCardPeople);
CFRelease(defaultSource);
ABAddressBookSave(addressBook, NULL);
}
else
NSLog(@"not granted");
NSLog vcardString はこちらです...
BEGIN:VCARD
VERSION:3.0
PRODID:-//Apple Inc.//iOS 6.1//EN
N:;Home;;;
FN:Home
EMAIL;type=INTERNET;type=HOME;type=pref:carljosdsdsewhnson.akasdssh@gmail.com
TEL;type=CELL;type=VOICE;type=pref:2323454645
PHOTO;ENCODING=b;TYPE=JPEG:/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAICAgICAQICAgIC
....LOT OF GIBBERISH....
END:VCARD