On Mar 8, 2017, at 15:25 , Jeremy Hughes <moon.rab...@virginmedia.com> wrote: > > My conclusion (for now) is that “needsDisplay” causes subviews to be redrawn > - except when “wantsLayer” has been set to true. > > Does that make sense?
Sure. In some cases, such as when using layers, the result of your “draw(_:)” methods for custom subviews can be skipped as an optimization, since their output might have been cached earlier in a backing store. “needDisplay” applies to the view(s) for which it is set. That means the “draw(_:)” method is called for that view (or those views). However, in a later part of the screen update process, this new drawing output must be composited with subview drawing output. For subviews that didn’t have “needsDisplay” set, this compositing can be done with the existing backing store, if available. Otherwise, the subview “draw(_:)” methods have to be called too, simply to (re)create the subview contents. It can be difficult to predict which drawing paths will be taken. One situation where subviews may already be cached is when you are using layers, since layers *are* drawing caches. So, the correct answer to your original question, I think, is that if your model data has changed in such a way that the representation in custom views no longer reflects the data, then you should set “needsDisplay” on *every* custom subview that uses “draw(_:)”. If you just need your changed view to be re-composited with the same subview contents as previously, then you don’t need to set “needsDisplay” on the subviews, just the parent view. _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com