Open shirakaba opened 1 year ago
I made a proof-of-concept of auto-marshalling for method params with type @
. If passed a primitive type like a napi_string
, it could be automatically marshalled into an NSString like so:
https://github.com/sandeepmistry/node-objective-c-runtime/commit/03928b2bf17f25e6af81916200919083aab2bbc4
Of course other primitive types like numbers could be handled the same way (marshalling to NSNumber).
Really interested in this project (I'm on the NativeScript TSC, and it feels like it has the potential to deliver a NativeScript-like experience for desktop), but just wish it would have some example usages. Here's what I've figured out so far:
Initialising an NSString instance (without a value)
Initialising an NSString instance (with a value)
I'm not quite sure how to pass an NSString as a method argument though.
This gives the error:
So clearly JS strings aren't automatically marshalled into NSString when the method's expected param type is
@
. Which makes sense, though leads to the next question. How can we call some of these NSString methods for making basic types?