native-dialog-rs icon indicating copy to clipboard operation
native-dialog-rs copied to clipboard

macOS: Use `objc2` crates

Open madsmtm opened this issue 1 year ago • 0 comments

These replace the objc family of crates, and provide a bunch of improvements on top, especially wrt. correct memory management.

Improvements that we use in native-dialog:

  • We no longer need to call msg_send!, (almost) all methods have automatically generated bindings in objc2-foundation.
  • AppKit bindings are provided in objc2-app-kit, so we no longer need to define NSEdgeInsets, NSOpenPanel and such manually.
  • bool is handled automatically, no need for the objc_bool conversion routine.
  • declare_class! is used to create the DropdownAction helper class.

For this initial transition, I decided to keep the I... extension traits around, to make the diff in src/dialog_impl/mac/file.rs minimal.

In the future, the MainThreadMarker type could be used to easily assert that things are happening on the main thread, to prevent issues such as https://github.com/native-dialog-rs/native-dialog-rs/issues/36.

madsmtm avatar May 01 '24 03:05 madsmtm