Luis
Luis

Reputation: 31

ABRecordRef vCard

I would like to convert a ABRecordRef into an vCard or NSData to transmit it via Bluetooth. I've run into your question and I wonder if you were able to figure out how to do it.

Thank you

Upvotes: 3

Views: 2419

Answers (1)

specktro
specktro

Reputation: 295

Is very easy, I'm working with iOS 6 and I done with the following code:

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);

I have a NSArray with ABRecordRef elements...

Upvotes: 7

Related Questions