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 14:27:17 -0700
> On Dec 6, 2016, at 1:33 PM, Carl Hoefs <email@hidden> wrote:
>
>> 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.
Followup: It turns out that the 'offending' line of code is:
[self.layer setDelegate:self];
If I don't set this, everything still works correctly, and there's no crash at dealloc time.
-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