我想将ABRecordRef
转换为vCard
或NSData
以通过蓝牙进行传输。我遇到了你的问题,我想知道你是否能够弄清楚如何去做。
谢谢
答案 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);
我有NSArray
个ABRecordRef
元素......