Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 823
Luis Avatar asked Mar 18 '26 14:03

Luis


1 Answers

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...

like image 69
specktro Avatar answered Mar 20 '26 02:03

specktro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!