Re: CALayer -drawInContext and GCD
Re: CALayer -drawInContext and GCD
- Subject: Re: CALayer -drawInContext and GCD
- From: "John C. Randolph" <email@hidden>
- Date: Thu, 02 Sep 2010 15:24:23 -0700
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 (email@hidden)
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:
This email sent to email@hidden