Re: breaking on fast enumeration mutation error?
Re: breaking on fast enumeration mutation error?
- Subject: Re: breaking on fast enumeration mutation error?
- From: Matt Neuburg <email@hidden>
- Date: Thu, 03 Dec 2009 08:46:43 -0800
- Thread-topic: breaking on fast enumeration mutation error?
On Wed, 2 Dec 2009 17:00:38 -0800, Kathy Tafel <email@hidden>
said:
>Hiya,
>
>I am catching an exception, a fast enumeration mutation error, but
>don't really see where I'm making the error. Could someone walk me
>through setting an appropriate breakpoint, as I am only working on my
>first project, or point to a how to? My KVO exceptions were helpful in
>telling me to set NSKVODeallocateBreak.... This says
>
>main: Caught NSGenericException: *** Collection <NSCFArray: 0x13aeb0>
>was mutated while being enumerated.
>
>It only ever happens on the iPhone, never in the simulator, when I am
>not debugging, when the rest of the system is wigging out on low
>memory, and when I've recovered from low memory several times. Think
>I'll go try to be more efficient about memory, but should probably
>find this. :/
>
>(have searched on every "for (", "removeObject", "addObject",
>"removeFromSuperview"...)
It's probably "removeFromSuperview", since if you are doing a for-loop on
myView.subviews, you are mutating subviews by removing a subview from
myView.
It's great that you were able to get an error message ("mutated while being
enumerated") because the fast enumeration error I was asking about a couple
of days ago didn't even log an error - it just crashed.
http://lists.apple.com/archives/cocoa-dev/2009/Nov/msg01704.html
And it apparently crashed without ever reaching removeFromSuperlayer. It's
as if the "for" loop itself was illegal. I never did figure it out (I just
worked around it by not using fast enumeration).
I am left with a vague suspicion that fast enumeration is a bit squiffy. But
I still use it all the time because it's such a good linguistic construct.
:) m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden