On Dec 26, 2009, at 13:58, Gideon King wrote:

> DrawRect is not called directly by you - instead, you use 
> setNeedsDisplayInRect: and setNeedsDisplay: to tell the system the dirty rect 
> to redraw, and those rects are combined before the system locks focus on your 
> view and calls drawRect:/ You therefore can't pass information to your 
> drawing method - you have to use the state information you set in your 
> program to work out how to draw the rects you need to draw.
> 
> HTH
> 
> Gideon 
> 
>> I have two classes. One for internet connection(program logic) and one to
>> display graphics(i posted code). And i want to call drawRect from another
>> class and pass some data to drawRect method. Seems like drawRect method is
>> just for static graphics. Does there's any possibility to do it ? Any
>> examples ?


In any case, it seems like short-sighted design to have a view's drawing 
methods called directly by another class (even if the concept made sense in the 
Cocoa scheme of things). Rather, provide a method for other classes to call 
that specifies their rect of interest and other parameters, and have that 
method decide how to get things drawn accordingly. This might be as simple as 
stashing the parameters in instance variables and invoking '[self 
setNeedsDisplayInRect: suppliedRect]', but might also get more sophisticated if 
there might be *multiple* invocations before drawing actually occurs, in which 
case you'd have to decide how to resolve the various sets of possibly 
conflicting parameters, right?


_______________________________________________

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