I’m trying to add new categories to the NSArrayController class: it can select the first and the last item. I did so:
I get no errors, but I would like to but this object in IB, using a blue cube and binding buttons to its “selectFirst” and “selectLast” methods.
But I’m a bit lost: which standard object to start with? A standard ArrayController? And then, which class name to choose to have the new methods listed?
The new methods appear in the binding window of the standard NSArrayController. Incredible. Once again it’s like magic. 10 more lines of IF-ed code gone – and it works.
Yes, of course, it was unclear from my post but I have a .h and a .m file.
Categories are really fun. As long as I don’t add instance variables/properties, I can obtain from a existing class just this “why didn’t they implement this method” extra work – and certainly reusable.
Thank you, Shane, your MyriadHelpers have inspired me!
Of course if I wanted something more complicated, like, for example, a NSSegmentedControl made of individual buttons instead of segments, able to send n different actions, subclassing would be unavoidable.
What I miss for the moment is a custom cell capable of implementing a NSColorWell into a standard cell-based table view. Still searching to subclass NSControlCell and filling the log console with pages of errors.