cacao icon indicating copy to clipboard operation
cacao copied to clipboard

Definition of NSWorkspace, NSNotificationCenter, and NSRunningApplication

Open agg23 opened this issue 1 year ago • 3 comments

Got a little carried away going down the rabbit hole of getting some notifications and NSWorkspace methods working. I believe this PR should cover the majority of usecases, though there are some uncommon methods that I did not implement (I left comments marking what is missing).

  • Introduces Retainable trait - Allows for a common way to build retain definitions and allows for the retain_nullable connivence method, which will be needed more and more as more nullable instance properties are implemented
  • Expands NSMutableDictionary methods to be more complete. Adds Iterator support - Note that the untyped nature of Objective-C collections makes dictionaries particularly difficult. Several methods assume NSString keys
  • Adds strum macros for generating NSString constants from enums, like what is used for NotificationName - I don't imagine there will be many other locations outside of NSNotification where this macro is used, but I think it's hugely helpful in this case.
  • Definitions for NSWorkspace, NSNotificationCenter, NSRunningApplication, and NSNotification - These are all interconnected and rely on each other, hence the expanding scope of this PR. Addresses #24

I know there's a lot of stuff here, so take your time. I'm sure there's many things to complain about.

agg23 avatar Jul 21 '23 20:07 agg23

So I'm musing about juggling pull requests here - I definitely do want these in cacao, however I think the objc2 PR might muck this PR up. Given that we're starting to look into fixing more internal core stuff, I'd like to do the objc2 stuff first just so we're not backtracking later on - so apologies in advance if I put this into an un-merge-able state.

ryanmcgrath avatar Aug 01 '23 06:08 ryanmcgrath

(Also: icrate has NS[Mutable]Dictionary iterators that doesn't require all the keys to be strings, so if you use that, you get iterators for free).

madsmtm avatar Aug 01 '23 12:08 madsmtm

That's perfectly fine. I think most of this becomes unnecessary with objc2 anyway.

agg23 avatar Aug 01 '23 14:08 agg23