Dimitry,

What I've done is created a reference counted class hierarchy to match part
of the Cocoa framework. It's only partially done, but it allows Pascal code
to be written to simplify interaction with native OSX frameworks and APIs
like AppKit in the following ways:

Using NSWindow class as an example:
https://developer.apple.com/documentation/appkit/nswindow

* TNSWindow mirrors NSWindow and uses an automatic reference counting
scheme to automatically release objects when they are are no longer needed.

* All methods and properties of NSWindow are provided by TNSWindow and
there is no need to pass native objects as handles to functions. It's
implicit in Self and the underlying handle is manged by TNSWindow ->
TNSResponder -> TNSObject  -> and ultimately TFrameworkObject.

* It uses an object oriented hierarchy the same as the Apple frameworks,
only translated to Pascal objects. That is you can pass a derived class to
methods of other object methods which may expect any less specific class.

* Other classes such as CGContext (TCGContext -> TFrameworkObject) are
provided as well as other Apple frameworks classes, all translated to
Pascal classes with all the same benefits as outlined above.

My implementation isn't complete, which is to say I haven't wrapped every
single Apple framework class in the manner described above. For the
extremely limited amount of translations I did complete, I saw a big
benefit in my own personal projects on OSX. Most notably the way of
organizing code I outlined above allowed me to much more easily understand
how to use Apple's frameworks, reduce errors with type safety and automatic
object lifetime management, as well as aid in the discovery when combining
Apple framework object to accomplish programming tasks. I expect if this
were integrated into the Cocoa widgetset it would make development a bit
easier. Certainly there is a lot of work involved in defining every Apple
framework object in this way, but it provides a certain level of
organization and usability that I at least feel makes a big difference when
working with native Apple APIs.
-- 
_______________________________________________
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to