I’m looking to wrap Apple’s Objective-C class hierarchy in AppKit. I’m reading the docs on calling C code, but it’s not obvious yet how to best wrap a class hierarchy. Any suggestions?
Example type relations, from the Objective C library:
NSTextField <: NSControl <: NSView <: NSResponder <: NSObject
NSTableView <: NSControl ...
NSWindow <: NSResponder ...
Would I declare empty mutable structs in Julia, and use ccall
with Ptr
to them?
mutable struct NSWindow end
mutable struct NSView end
mutable struct NSTextField end
ccall(:addSubview, Nothing, (Ptr{NSView}, Ptr{NSView}), cv, tf)
In Objective C (technically I’m using Objective C++):
extern "C" void addSubview(NSView *a, NSView *b) {
[a addSubview:b];
}
That actually “works” in my little test program I’ve got so far, but as you can see I’m not declaring any kind of relationship between the types.
Maybe I can call objc_msgSend with ccall
, and avoid writing lots of little wrapper functions like addSubview
there.