On Aug 13, 2009, at 10:33 AM, Daniel Furrer wrote:

You are right. (But why?)

When/where are you trying to do this? I tried running this in main.m, before calling NSApplicationMain(), and got nil returned from +controlColor.

I moved it into an -awakeFromNib call, and +controlColor returned a valid object. That leads me to believe that some connection needs to be hooked up for this to work, and at the time you're calling it (as I did in main.m) that this connection is not configured yet. I'll leave it to smarter gurus here to describe what that "connection" is. WindowServer? AppKit?

On Thu, Aug 13, 2009 at 6:29 PM, Randall Meadows <cocoa-...@not- pc.com> wrote:
On Aug 13, 2009, at 10:24 AM, Daniel Furrer wrote:

I'm trying to get the RGB components of a system color. Here's what I've
been trying:

  NSColor* foo = [[NSColor controlColor] colorUsingColorSpaceName:
@"NSCalibratedRGBColorSpace"];
  NSLog(@"%f, %f, %f", [foo redComponent], [foo blueComponent], [foo
greenComponent]);

but all I ever get is 0.0, 0.0, 0.0
Also [foo numberOfComponents] seems to be 0. (For [NSColor blueColor] it's
working fine however).
What am I doing wrong?

Sounds like foo is nil. Have you verified that it is a bona fide object in the debugger?



--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?




_______________________________________________

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

Reply via email to