Improve type safety
Closed this issue · 1 comments
brendanzab commented
I realise that Objective-C is a very loosely typed language, but it might be easier to work with the API if we enforce some type safety:
pub struct id(libc::intptr_t);
pub const nil: id = id(0);
pub struct NSWindow(id);
pub struct NSString(id);
...
impl Deref<id> for NSWindow { fn deref(&self) -> &id { ... } }
impl Deref<id> for NSString { fn deref(&self) -> &id { ... } }
...
I came up against this when trying to implement invoke_msg_void_NSInteger
on NSInteger
in #36 because it overlapped with id
. It would also improve the documentation.
brendanzab commented
Closing - I think I have a better way of doing this now in https://github.com/bjz/objc-rs