I have, let’s say, NSArray containing NSStrings in my objective c code of native extension. I need to have it in HaXe code as Array<String>. What is the right way to transfer it?
As far as i understand, i need first to transfer it to some function in cpp code (declared in ExternalInterface.cpp) which then calls (via val_call) HaXe callback and passes data to it. I’m pretty sure there is no way to transfer NSArray or even just NSString as is. But i cannot figure out how to convert it to something that can be passed through.
I’ve found from other extensions source code that NSString should be passed as const char* via [myNSStringVar UTF8String], but still have no idea on how to pass array.
This definitely should do the trick on transferring small structures. But in cases of some “big data” JSON could fail. I’ve tried to pack ~140kb string to JSON recently on neko target - failed as expected.
Anyway, packing to JSON reflects “keep it simple stupid” approach. And sometimes it is all we really need.
And i’ve just took a look at hx/CFFI.cpp in hxcpp project - good place to learn how allocs and vals are working. It isn’t documented well at the moment, am i right? At least i cannot find available documentation for this.
I’ll describe and share my solution on topic after implementation.