RE: NSColorWell and NSColor Category
RE: NSColorWell and NSColor Category
- Subject: RE: NSColorWell and NSColor Category
- From: "Jonathan E. Jackel" <email@hidden>
- Date: Wed, 27 Aug 2003 10:26:01 -0400
>
I'm trying to write a category to NSColor to get a dictionary
>
reprentation of a color.
>
My problem is that works fine If I call my category on a newly
>
allocated color like [ NSColor blackColor ] but not on the color I get
>
from [ myColorWell color ].
What happens? Have you tried NSLogging calls to your method? Is your
method being called at all?
I suspect your method is being called, but that you may be asking the
colorwell color for information that doesn't exist in its colorspace.
You'll need to test for that. Check the "Using Color" documentation for
details.
By the way, how do you know whether [NSColor blackColor] is "newly
allocated"? It could be implemented as a single shared instance. I think
this misunderstanding may have caused you to misdiagnose the problem.
>
>
Is there a specific place where I have to declare my Category ?
Just import the category's .h file into the .m file where you use category
methods. Sounds like you've done that.
>
Perhaps my NSColor already exists in memory (shared, into
>
NSColorPicker) and my category is ignored ?
No, it doesn't work that way. Every NSColor object should respond to your
method.
>
>
Another solution could be to quickly copy a color with
>
something like
>
[ NSColor colorWithColor: myColor ] but that does not seem to be
>
possible.
newColor = [[myColor copy] autorelease];
Jonathan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.