The new way will fail too. It will throw a ConcurrentModificationException. If you think the array will change then best thing to do, if your working with NSArray, is to clone the array and then iterate over the clone like so:

        for(Object obj : myArray.immutableClone()) {
                /* Do Something With obj Here. */
        }

--
Galen Rhodes
[EMAIL PROTECTED]


On Mar 19, 2008, at 2:17 PM, Guido Neitzer wrote:
On 17.03.2008, at 14:28, Gaastra Dennis - WO Lists wrote:

This is how we are retrofitting most of our array loops; now since WO 5.4:

public void doThisForAllProducts(EOEditingContext ec) {
        for (Product aProduct : products())
                aProduct.doThis(ec);
}

Nice and simple, eh?

What if someone changes your array while you're working on it? I don't know what this new style will produce, but the very old style with:

for (int i = 0; i < array.count(); i++) {
        // do something
}

could fail if someone changed the relationship behind your back.

cug

--
http://www.event-s.net

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/grhodes%40thissmallworld.com

This email sent to [EMAIL PROTECTED]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to