ABRecordRef vCard

时间:2010-02-25 23:37:09

标签: iphone objective-c ios abaddressbook vcard

我想将ABRecordRef转换为vCardNSData以通过蓝牙进行传输。我遇到了你的问题,我想知道你是否能够弄清楚如何去做。

谢谢

1 个答案:

答案 0 :(得分:7)

非常简单,我正在使用iOS 6,我完成了以下代码:

ABRecordRef person = (__bridge ABRecordRef)[_ABRecordCards objectAtIndex:0];
ABRecordRef people[1];
people[0] = person;
CFArrayRef peopleArray = CFArrayCreate(NULL, (void *)people, 1, &kCFTypeArrayCallBacks);
NSData *vCardData = CFBridgingRelease(ABPersonCreateVCardRepresentationWithPeople(peopleArray));
NSString *vCard = [[NSString alloc] initWithData:vCardData encoding:NSUTF8StringEncoding];
NSLog(@"vCard > %@", vCard);

我有NSArrayABRecordRef元素......