| Article: |
Building a Scratch Pad with Cocoa | |
| Subject: | works but with warning (short code eg.) | |
| Date: | 2001-12-10 09:24:48 | |
| From: | psheldon | |
|
Response to: NSBezier subclass creation set with no get accessor
|
||
|
ColorBezier.m:20: warning: instance variable `theColor' accessed in class method
|
||
Showing messages 1 through 1 of 1.
-
got rid of warning with accessor and less self
2001-12-11 10:15:44 psheldon [View]



When I tried to make a new version that used a ColorWell, all my plans went haywire, as I doubted I had understood memory managment deep in my bones. I threw in retains and releases and perhaps too many retains knowing that when I quit, it would clean house, maybe. Still no change of color. I think the click in the color well ran the mousedown method and I got messages about not having a point for a line as soon as I tried to draw. I got rid of those error messages, without understanding them really, by insuring that I last clicked on a button I called "Well" by putting code assigning a new path in the action associated with that button in padView.
So, having gotten rid of an error message, I went on to see that my color didn't change because my ColorBezier subclass of NSBezierpath didn't change. So, perhaps I don't know how to think in assigning currentPath because of this pointer retain and release stuff not having sunk in.
Perhaps the button and colorwell actions may illustrate my confusion rather than all my code :
- (IBAction)ChooseWell:(id)sender
{
[pathCurrent release];
pathCurrent = [ColorBezier initWithColor: colorCurrent];
[pathCurrent retain];
[ColorPaths addObject: pathCurrent];
}
- (IBAction)colorWellAction:(id)sender
{
float *locRed,*locGreen,*locBlue,*locAlpha;
[colorCurrent release];
colorCurrent = [sender color];
[colorCurrent retain];
//[colorCurrent getRed:locRed green:locGreen blue:locBlue alpha:locAlpha];
[colorCurrent set];
//[colorCurrent getRed:locRed green:locGreen blue:locBlue alpha:locAlpha];
}