On May 17, 2011, at 12:58 PM, David Duncan wrote:

> The basic problem comes about when a view in the nib has wantsLayer=NO, but 
> the view itself always wants to be layer backed. If you setWantsLayer:YES 
> inside of -initWithFrame:, then by the time you get to -awakeFromNib 
> wantsLayer=NO again. As such, if you did anything that relied on the view 
> being layer backed (such as setting its layer and manipulating the layer 
> tree) then that work needs to be done again.

I get it. Thanks.

> However, this should not apply to any layers you create that aren't implanted 
> into the view. You should be able to create layers to your hearts content 
> inside of -initWithFrame: as long as you don't try to manipulate the view's 
> layer tree. As such your statement that you couldn't create layers there 
> seems to be indicative of some other issue.


I agree that the explanation doesn't logically lead to a prohibition on 
creating layers in -initWithFrame:. That's why I initially created them there, 
deferring only the construction of the layer tree to -awakeFromNib. But I 
suffered random failures -- in fact, the application failed more often than 
not. The randomness is consistent with my doing something to which the phrase 
"undefined behavior" is often applied in Apple documentation. Now that I've 
moved the layer creation to -awakeFromNib, however, my application is working 
correctly 100% of the time.

100% of past time, that is. As to future time, I don't know yet.  ;->  That's 
the trouble with random failures....

-- 

Bill Cheeseman - b...@cheeseman.name

_______________________________________________

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