Hi all,

I find myself often times needing to iterate through an NSArray of EOs. I'm not sure if the way I'm doing it is the most effecient or not. Here's what I normally do:

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

This is assuming that products() is an NSArray of Product EOs.

Is this a good / the best way to iterate through NSArrays in general?

I find myself occasionally nesting this loop a couple deep to drill down into several toMany relationships. For example (as a keypath): products.billsOfMaterial.routingSteps.components to get all the components that are possibly used in a product.

On a side note, and the reason for calling products().toArray() is to force EOF to get the real EOs and not just faults. If I just call products() I'll sometimes get EOs, sometimes faults, seemingly by EOF whim. Is that a bug or expected behaviour?

Thanks!

Dave
 _______________________________________________
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