• 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
Comparing NSColor instances
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Comparing NSColor instances


  • Subject: Comparing NSColor instances
  • From: Ricky Sharp <email@hidden>
  • Date: Sun, 4 Nov 2007 20:29:15 -0600

I have the need to compare multiple NSColor instances to see if they all represent the same color. This is so I can correctly support multiple selection in a new IB 3.0 plugin.

My first approach was to "normalize" all colors like so:

NSColor* normalizedColor = [aColor colorUsingColorSpace:[NSColorSpace genericRGBColorSpace]];

Then, extract the RGB components with getRed:green:blue:alpha: so I could do a simple comparison of them.

But, when calling getRed::::, I get the following in the Console:

*** -getRed:green:blue:alpha: not defined for the NSColor NSCustomColorSpace Generic RGB colorspace 0 0 0 1; need to first convert colorspace.

Also tried deviceRGBColorSpace, but got the same results.


I know this is possible as Apple has a solution. If you inspect two or more instances of an object in IB such that one the object's attributes links to an NSColorWell, the color well reverts to a default (black) should the object instances have different color values.



Searching for this issue just brought up the fact that the "problem is tricky to solve" and that one should look at color spaces. I would have thought normalizing to a common color space would have done the trick.


___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________

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


  • Follow-Ups:
    • Re: Comparing NSColor instances
      • From: Ricky Sharp <email@hidden>
  • Prev by Date: Re: FYI - installer packages are the preferred deployment method now
  • Next by Date: Re: Smart way to get "etched" borders in Leopard
  • Previous by thread: Buttons stopped responding to clicks
  • Next by thread: Re: Comparing NSColor instances
  • Index(es):
    • Date
    • Thread