Re: NSColor Unable to be stored?
Re: NSColor Unable to be stored?
- Subject: Re: NSColor Unable to be stored?
- From: Ali Ozer <email@hidden>
- Date: Wed, 30 May 2001 00:50:29 -0700
The colorWithDeviceRed:green:blue:alpha: function returns an
autoreleased value (all methods other than new, alloc, and copy do
this), so if you want to hang on to the value, you should copy it (or
retain, for objects which don't implement copy).
So,
storedColor = [[NSColor colorWithDeviceRed:1.0 Green:1.0 Blue:1.0
Alpha:1.0] copy];
>
Now this seems pretty simple to me, and I cannot for the life of me
>
understand why it won't work. I get an error saying "NCSFString -set:
>
selector not recognized" or something similar. Is this a special case,
>
or am
>
I missing something obvious? Any help is appreciated.
The error you're getting is the classic
object-gets-freed-and-the-memory-is-replaced-by-some-other-object
problem...
Ali