• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Why is "set" a class method of NSColor?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is "set" a class method of NSColor?


  • Subject: Re: Why is "set" a class method of NSColor?
  • From: Jack Boyce <email@hidden>
  • Date: Thu, 3 Dec 2009 18:54:19 -0800

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 <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >Why is "set" a class method of NSColor? (From: Jack Boyce <email@hidden>)

  • Prev by Date: Why is "set" a class method of NSColor?
  • Next by Date: beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector: on 10.6
  • Previous by thread: Why is "set" a class method of NSColor?
  • Next by thread: Re: Why is "set" a class method of NSColor?
  • Index(es):
    • Date
    • Thread