views:

185

answers:

2

H,

I have an NSBezierPath that I created and I called -stroke on it. How do I remove/delete it from the view without deallocating the object.

Thanks - Rebecca

A: 

If you want to temporary disable drawing, you can set [NSColor clearColor] before calling stroke.

weichsel
+5  A: 

A -stroke message tells the NSBezierPath to render itself in the current drawing context. If you've drawn a path in a view, and you want the stroked path to go away, just redraw the view without the path.

NSResponder
To add to this explanation somewhat: It's important to realize, when drawing on your view (or an image, etc.), you're not "adding a path object to the view object", you're using the information from the created path to draw it onto the view. Once drawn, you can't "remove" it - you'll have to redraw the view (or a given rectangle within it).
Joshua Nozzi