• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CALayer -drawInContext and GCD
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >CALayer -drawInContext and GCD (From: Vincent Habchi <email@hidden>)
 >Re: CALayer -drawInContext and GCD (From: David Duncan <email@hidden>)
 >Re: CALayer -drawInContext and GCD (From: Chris Parker <email@hidden>)
 >Re: CALayer -drawInContext and GCD (From: David Duncan <email@hidden>)
 >Re: CALayer -drawInContext and GCD (From: vincent habchi <email@hidden>)
 >Re: CALayer -drawInContext and GCD (From: David Duncan <email@hidden>)

  • Prev by Date: Re: UIView animation
  • Next by Date: Re: Core Data fetch performance, design pattern sought
  • Previous by thread: Re: CALayer -drawInContext and GCD
  • Next by thread: Re: CALayer -drawInContext and GCD
  • Index(es):
    • Date
    • Thread