Re: File Extensions Problem
Re: File Extensions Problem
- Subject: Re: File Extensions Problem
- From: Graham Cox <email@hidden>
- Date: Fri, 29 Aug 2008 10:12:30 +1000
On 29 Aug 2008, at 4:28 am, Ken Thomases wrote:
On Aug 27, 2008, at 5:59 PM, R.L. Grigg wrote:
Hmm, I guess the wrinkle in this particular case is if the
"contract" doesnt specify something that the programmer assumes to
be safe to do (like enumerating backwards), how can you know how to
implement your end?
Enumerating NSArrays backwards is safe and supported by the
framework. The earlier discussion had to do with mutating a
collection while enumerating, which is explicitly stated to be
unsafe. Somebody (I forget who) claimed that mutating was "safe"
while enumerating backwards, but they were wrong. In this case,
their wrongness was not based on things left unsaid in the contract,
but on violating things explicitly laid out in the contract.
Well, that was me. But I do see the error of my ways... I guess it was
Michael Ash's comment that NSArray *could* change its storage half way
through enumeration (if the collection were mutated) that woke me up.
I suspect it would only do this if the collection dramatically changed
in size but clearly that wouldn't be something to rely on. I checked
my own code to make sure I wasn't following my own "advice" anywhere
and turns out I've never done it without making a copy anyway.
cheers, Graham
_______________________________________________
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