core-foundation-rs
core-foundation-rs copied to clipboard
Higher-level interface to create delegates
It seems currently the only way to create e.g. an NSWindowDelegate is through objc::declare::ClassDecl interface:
let superclass = Class::get("NSObject").unwrap();
let mut decl = ClassDecl::new("MyWindowDelegate", superclass).unwrap();
decl.add_method ...
Should this crate expose trait NSWindowDelegate and make the creation of such delegate more type-safe?
Neither NSObject nor MyWindowDelegate are about Core Foundation, so I'm not sure why such a thing should exist in that crate. What makes you think so?
Did you mean to file that on the objc crate, maybe?
True, this is not about Core Foundation, but it is about Cocoa, which is a part of this crate.
This crate defines trait NSWindow for one of the core Cocoa interfaces. The interface provides setDelegate method to set NSWindowDelegate implementation which controls window behavior. Now currently the binding for this method looks like setDelegate_(self, delegate: id) so I can put any object there. I can create this object via objc crate, but I was wondering if this is too low-level and if we want to provide type-safe API in this crate to create such a delegate object.
Oh I see.
Any update ? I was also using setDelegate and didn't find any other way than the one mentionned by @vbo , may I create a pull request to implement a more high level inteface ?
A higher level interface sounds like a useful improvement, yes.
I tried something in #314