I would like to ask the group if this is "good practice" ( I am almost certain it is not "best practice" :-) )
My question pertains to knowingly setting an object to NULL and then knowingly sending it a message as an acceptable technique. (If this is not done, drawRect will simply show the oval as if it was still being actively drawn). The challenge was to design a doc based app that allowed a user to draw arbitrary ovals. Very briefly, I used the outline of "Cocoa design patterns" by using an NSArray of objects in a "controller" object ( in this case "MyDocument") which defined a bezierpath, and in the "drawRect" method of the view, used this code. - (void)drawRect:(NSRect)dirtyRect { ....code to fill background of viewObject.... /* now load the stored ovals from the array */ for (NSBezierPath * oval in [[ self delegate] ovals]) { ....code to set saved color.... [oval fill]; } /*paint the currently drawn user path (where currentPath is an ivar in the NSView Object) */ ..code to change color to "working" color .... [[self currentPath] fill]; } Now...In order to provide visual feedback on the mouseUp event ( the oval changes color to show that it is now saved) I set the current path to NULL thus. - (void)mouseUp:(NSEvent *)theEvent { ....code that sets the current mouseDown point and creates the current bezier path..... ...code that adds the current bezierpath to ovals list ..... [self setCurrentPath:NULL]; /*sets the current bezierPath to nil */ [self setNeedsDisplay:YES]; As mentioned above, this does work, but seems ?sloppy?. Thanks. _______________________________________________ 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