Re: iOS 9: Adding CALayer to self.view.layer causes EXC_BAD_ACCESS
Re: iOS 9: Adding CALayer to self.view.layer causes EXC_BAD_ACCESS
- Subject: Re: iOS 9: Adding CALayer to self.view.layer causes EXC_BAD_ACCESS
- From: Carl Hoefs <email@hidden>
- Date: Tue, 06 Dec 2016 13:33:11 -0700
> On Dec 6, 2016, at 1:24 PM, David Duncan <email@hidden> wrote:
>
> Your safest bets are to either clear the delegate of the layer at an appropriate time (possibly in your view controller’s dealloc is all that is necessary), or to use a UIView instead of a raw CALayer in this case. Removing the layer would also suffice, as that would prevent UIKit from seeing it at the time in question. Making the layer weak is probably causing your reference to deallocate before it can be added to the layer tree, which is why it doesn’t display in that case.
Thanks for this explanation, David!
I've verified that using either of:
[self.layer setDelegate:nil];
or
[self.layer removeFromSuperlayer];
will prevent the crash. It's just a bit
surprising to me that this is needed...
-Carl
_______________________________________________
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