Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create CFArrayRef

I'm trying to convert just ONE iPhone contact to a vCard using the build in methods. The docs say to use:

ABPersonCreateVCardRepresentationWithPeople(CFArrayRef people)

... but my delegate method gives me this:

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person;

I can't figure out how to create a CFArrayRef with just a single ABRecordRef.

The docs pointed me to CFArrayCreate() which confused me even more. I don't know enough C to figure this out on my own. I read in SO that NSArray had something called toll-free bridging and should be interchangeable with CFArrayRefbut didn't quite understand how to use it since the compiler complained when I tried just swapping them.

like image 878
Julian Avatar asked Jul 14 '12 06:07

Julian


1 Answers

toll-free bridging:

where array is kind of class: NSArray

CFArrayRef arrayRef = (__bridge CFArrayRef)array;
like image 96
Jesse Gumpo Avatar answered Oct 06 '22 00:10

Jesse Gumpo