This is a little thing I think I’ll start doing to relieve frustration after working with awfully designed or just plain buggy classes. Half Arsed Class will pick out classes that have pissed me off from AppKit, Foundation and UIKit. Hopefully I’ll also be able to retract these on a semi-regular basis.
Today’s Half Arsed Class is brought to you by the NSRulerView
class, which allows you to set a completely custom measurement unit setup so that you can draw rulers against your NSScrollView
instances.
Sadly, there’s no way to actually get those measurement units back. So, if you want to customise how the ticks on your ruler are drawn you’re completely out of luck. You’ll have to do all of the calculations, all of the math, and all of the drawing yourself.
The default NSRulerView
also updates as required to reflect the magnification level of the scroll view it’s tied to. Via a private instance variable. With no other piece of the puzzle exposed.
*mouth fart noise*
It gets better! The documentation makes reference to:
“If you want to do custom hash-marks and labels you should first look at doing it with a delegate. You can do whatever kind of custom hash-marks you want through delegation as long as the hash-marks and labels are evenly spaced.”
However, there are no delegate methods that expose anything to do with customising the hash marks. Brilliant QA work there, guys!
So, if you find yourself thinking “NSRulerView looks like what I need!”, think again. It’s only useful if you want it in exactly the form you find it.
Radar filed: I need a drink.