On Sep 2, 2010, at 3:17 PM, David Duncan wrote:

> On Sep 2, 2010, at 11:29 AM, vincent habchi wrote:
> 
>> You mean I shall use your dispatch_async invocation instead of calling 
>> [layer setNeedsDisplay]?
> 
> Calling -setNeedsDisplay arranges for -display to later be called on the 
> current runloop. As such using -setNeedsDisplay is reliant on a runloop 
> running (and running regularly) neither of which you have on a GCD queue.
> 
>> I was thinking of calling dispatch_async () inside -drawInContext, but, if I 
>> understand your example correctly, this is wrong.
> 
> Doing so would cause you all manners of pain and suffering, the most common 
> of which is things "mostly" working but occasionally your drawing going into 
> the wrong view. Basically *never* use the context given to you in 
> -drawInContext: outside of that invocation.

More generally,  -draw…: methods should never have side effects, whether we're 
talking about a layer, a view, or what have you.

-jcr

_______________________________________________

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