Re: CALayer removeFromSupeLayer crashes
Re: CALayer removeFromSupeLayer crashes
- Subject: Re: CALayer removeFromSupeLayer crashes
- From: Dennis Christopher <email@hidden>
- Date: Tue, 13 Jan 2009 08:51:12 -0500
Matt,
Thanks for this reply. I will reply back to the list once I get this
solved so others can benefit from it.
updateRemovedSublayer is however CALayer's not mine. I have no need to
access individual layers, if it is ok just to call [[self layer]
setSublayers:nil], as Dave Duncan suggested.
Dennis
On Jan 12, 2009, at 9:25 PM, Matt Long wrote:
Dennis,
If any of your layers are autoreleased and not explicitly retained, if
you try to access them again, you will get a crash. Can you show us
what your functions such as updateRemovedSublayer look like (I'm
assuming that's yours)? If you are calling [CALayer setSublayers:nil]
and then try to access one of the layers that was in the previous
array, it will crash as they have been released. If you allocate your
layers with alloc init, you will still have a reference to the layer.
Then, when it is removed from the parent layer, you can still access
it. On the other side of that, though, you will need to explicitly
release the object when you are done.
Best regards,
-Matt
On Jan 12, 2009, at 1:57 PM, Dennis Christopher wrote:
Dave,
Thanks for the pointer. I had corrected the original array
enumeration error, and forgotten. But no matter how I try to access
a sublayer I seem to have a problem.
When I now try your suggestion I still get a crash. The call stack
shows, in order of execution:
[CALayer setSublayers:]
CALayerUpdateSublayers
updateRemovedSublayer
CALayerMarkVisible
.
.
objc_msgSend (EXC_BAD_ACCESS)
Can you suggest what might be wrong?
Dennis Christopher
On Jan 10, 2009, at 12:43 PM, David Duncan wrote:
On Jan 9, 2009, at 12:19 PM, Dennis Christopher wrote:
NSArray *theLayers = [[self layer] sublayers];
for(CALayer *layer in sublayers) {
[layer removeFromSuperlayer];
I'm new to CALayer and at a loss as to what could be wrong with
this.
Any suggestions would be appreciated.
(I've read through most of Dudney's Core Animation book but
nothing
jumps out at me.)
I would suspect that you'd see a message on the console to the
effect
of "modifying an array while enumerating it". I think you can
replace
this more simply by just doing [[self layer] setSublayers:nil].
--
David Duncan
Apple DTS Animation and Printing
_______________________________________________
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
_______________________________________________
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