On Nov 24, 2010, at 9:50 AM, Artemiy Pavlov <artemiy.pav...@ukrpost.ua> wrote:

> I have a view whose drawRect method draws a plot according to a few 
> parameters which are global variables. When I change these variables 
> according to the user input, I want to update that plot, so I need the 
> drawRect method of my view to be called. I tried [self setNeedsDisplay] or 
> [MyView setNeedsDisplay] but this doesn't work.

(I assume you're referring to -drawRect: and -setNeedsDisplay:, as the colons 
are part of Objective-C method names, not separate syntax.)

In what way doesn't this work for you?

Do you mean that after you make a change, your view isn't redrawn the next time 
through the run loop?

Or do you mean that when you change a property on your view, you expect the 
view to draw immediately rather than at another part of the run loop?

Finally, and to cover all bases, are you changing the property on your view in 
the main thread, or in another thread?

You should just ensure changing properties on your view (or property changes on 
the data your view is observing) causes the view to invoke either [self 
setNeedsDisplay:YES] or [self setNeedsDisplayInRect:affectedRect]. Cocoa will 
generally ensure your -drawRect: is invoked at the right time after that.

  -- Chris

_______________________________________________

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

Reply via email to