bind icon indicating copy to clipboard operation
bind copied to clipboard

Wrap ObjC objects with a Haxe class (written in Haxe)

Open jeremyfa opened this issue 6 years ago • 0 comments

At the moment, the (Haxe compatible) class that wraps Objective C objects is written in C++ (taken from HXCPP itself).

This is a problem in a sense that it increases the chances to break if HXCPP changes internals on how it implements Haxe classes in C++. It also makes it more difficult to add additional helpers on this wrapper class (like an explicit release() method).

Instead, we can create a regular Haxe class that wraps and retain an Objective-C object, and releases it when being destroyed.

We could provide an explicit release() method on this ObjcWrap class, but also automatically release the Objective-C object when the wrapper is being Garbage Collected, thanks to cpp.vm.Gc.setFinalizer().

(the setFinalizer() solution was already experimented there: https://github.com/jeremyfa/hx2objc/blob/master/hx2objc/IDHolder.hx)

jeremyfa avatar Aug 23 '17 17:08 jeremyfa