• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: removing all sublayers from a layer with fast enumeration
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: removing all sublayers from a layer with fast enumeration


  • Subject: Re: removing all sublayers from a layer with fast enumeration
  • From: Nick Zitzmann <email@hidden>
  • Date: Mon, 30 Nov 2009 12:36:51 -0700

On Nov 30, 2009, at 12:23 PM, Matt Neuburg wrote:

> To remove all sublayers from a layer, it is sufficient to set that layer's
> sublayers property to nil, so this code is completely unnecessary. But I'm
> just curious as to why it doesn't work:
>
> for (CALayer* sub in myview.layer.sublayers)
>  [sub removeFromSuperlayer];
>
> This crashes as if the fast enumeration itself were somehow illegal. Why?

What happens if you try enumerating on a copy of the sublayer array? That's what I usually do in this situation...

Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________

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

References: 
 >removing all sublayers from a layer with fast enumeration (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: removing all sublayers from a layer with fast enumeration
  • Next by Date: Re: removing all sublayers from a layer with fast enumeration
  • Previous by thread: Re: removing all sublayers from a layer with fast enumeration
  • Next by thread: Re: removing all sublayers from a layer with fast enumeration
  • Index(es):
    • Date
    • Thread