Re: File Extensions Problem
Re: File Extensions Problem
- Subject: Re: File Extensions Problem
- From: Phil <email@hidden>
- Date: Sat, 23 Aug 2008 00:15:03 +1200
On Fri, Aug 22, 2008 at 10:23 PM, Graham Cox <email@hidden> wrote:
> You shouldn't go modifying the array in general, for sure. But the special
> case of modification by deleting the last item in the array is safe, and
> always will be. In fact deleting any item with a higher index than current
> is safe, and always will be. Why? Because an ordinary for loop that counts
> down is free to do this and the existence of such loops in shipped code
> means that NSMutableArray can never be changed in such a way as to break
> code like that. (It's also hard to see how it could be, even theoretically).
>
Although an NSEnumerator is analogous to a for loop using an index
variable, that doesn't make the contract on them the same.
NSMutableArray can't be changed to break the traditional for loop that
modifies the array, but the NSEnumerator returned by NSMutableArray
can be.
You're making an assumption about the implementation of how the
enumerator moves through the list; and although I think this is a sane
assumption (any other way of enumerating through the list would be
strange), you're still breaking the contract of NSEnumerator. There is
no documented exception about the objects that have already been
enumerated over, so it shouldn't be assumed that there is one.
Phil
_______________________________________________
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