News for hackers. Stuff that matters.

kattrali

Re:Building native macOS applications with Rust on Wednesday November 30, 2016 @05:16PM (#13075223)
> How do you subclass an ObjC class from Rust — say, to create a delegate for a UI element?

The objc::declare module includes ClassDecl, which enables registering a new Objective-C class.

objc::declare documentation: http://sasheldon.com/rust-objc/objc/declare/index.html

Example usage: https://github.com/kattrali/rust-mac-app-examples/blob/maste...

> How is type safety handled? It looks like msg_send itself isn't type safe, but there are hand-written bindings… is that right?

Correct. msg_send operates on objc::runtime::Object references. The handwritten bindings use the impl_objc_class macro referenced in the post to define separate types for different Objective-C classes, and make messaging the wrong type of object a compile-time rather than a runtime error.

The impl_objc_class macro implements the ObjCClass and PartialEq traits for a new type: https://github.com/kattrali/rust-mac-app-examples/blob/maste...

Re:Building native macOS applications with Rust on Wednesday November 30, 2016 @03:32PM (#13074429)
You can take either approach. I opted to do it in code[0] as a personal preference since it reduced the amount of time spent jumping between Xcode and Vim, but creating a xib or storyboard and referencing it from Rust using NSBundle resources is just as possible. Maybe I should add examples of using resources to the code samples in the blog post. Thanks!

0: https://github.com/kattrali/webkitten/blob/6ac4ced187b44fe91...

Re:Alcatraz – Package manager for Xcode 5 on Monday March 03, 2014 @01:02PM (#7335212)
Alcatraz isn't a CocoaPods wrapper, it is an installer for Xcode customizations like plugins and color schemes. You can use it to install a CocoaPods Xcode plugin to handle installing and updating pods though: https://github.com/kattrali/cocoapods-xcode-plugin