Drawing With Colors
- While it's normally spoken of as an Object Oriented approach, Cocoa is occasionally a little bit Magic Oriented (Mystery Oriented?). You would think that if you're drawing in an NSView (or a subclass of NSView) that the color would be set via an NSView method (or maybe a method of the line or shape you're drawing). Instead, you send a
setmessage to an NSColor object which, typically, isn't created or referenced until right before drawing in the view. It's common to find lines of code like
[[NSColor redColor] set];in a method that draws in a view. Such lines automagically tell the view which color to use in subsequent drawing instructions.
Найдено коллегой тут.
p.s. завёл новый юзерпик по этому поводу :-)