Argh, never mind. I overlooked an important section of the Cocoa Drawing Guide.
Jack On Thu, Dec 3, 2009 at 6:46 PM, Jack Boyce <jbo...@gmail.com> wrote: > I'm learning Cocoa, trying to understand certain "magical" features where > it isn't obvious how things work under the hood. (KVO and isa-swizzling is > another prime example.) > > Can someone kindly explain, or point me to an explanation for, what's > really happening with: > [[NSColor blueColor] set]; > > In other APIs one commonly sees methods on the target view for setting > things like pen color and transformations. I.e., why is it not: > [myView setPenColor:[NSColor blueColor]]; > > In particular, how does the NSColor object know which NSView you're talking > about when you send it the 'set' message? My current hypothesis is that > information like pen color is recorded somehow in the [NSGraphicsContext > currentContext] object for the current thread, but I can't confirm this in > the docs. This would imply Cocoa is doing work behind the scenes to set up > the NSGraphicsContext before it calls your view's drawFrame: method, and > then cleaning up when you return. Is the idea then that one should only > draw within the drawFrame: method of NSView, and only from the main thread > (when Cocoa calls it)? I.e., there is no multi-threaded drawing in Cocoa? > > Thanks, > Jack > > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com