David,

Compare:

NSMutableArray allBillsOfMaterial = (NSMutableArray) aBillOfMaterialComponent.valueForKeyPath("part.billsOfMaterial");

NSArray scheduledRoutingBillsOfMaterial = (NSArray)((BillOfMaterial) aScheduledRouting.valueForKey("routing")).valueForKeyPath ("part.billsOfMaterial");

I think you may be surprised to find that allBillsOfMaterial and scheduledRoutingBillsOfMaterial are two references to the same array being returned by valueForKeyPath().

I could be wrong about this, but I don't see any reason why valueForKey or valueForKeyPath would automatically give you a copy of the original array. It's my understanding that it will give you a reference to that original array. How you cast the result is not going to change the reference handle to the object or give you a new instance of the array.

On Mar 27, 2007, at 9:41 AM, David Avendasora wrote:

They are in two separate classes. Each are defined from scratch. Both are defined using key-value coding.

The code that retrieves that filters the array is: (it is located in one of my core entity classes) NSMutableArray allBillsOfMaterial = (NSMutableArray) aBillOfMaterialComponent.valueForKeyPath("part.billsOfMaterial"); log.debug(aBillOfMaterialComponent.valueForKeyPath ("part.partDescription") + " has "+allBillsOfMaterial.count()+" BOM (s).");
                                        if (allBillsOfMaterial.count() > 1) {
EOQualifier BOMqual = new EOKeyValueQualifier("isDefault", EOQualifier.QualifierOperatorEqual, new Integer(1)); EOQualifier.filterArrayWithQualifier(allBillsOfMaterial, BOMqual);
                                        }

The code for the second is located in a web component:
    /** @TypeInfo BillOfMaterial */
    public NSArray scheduledRoutingBillsOfMaterial()
    {
scheduledRoutingBillsOfMaterial = (NSArray)((BillOfMaterial) aScheduledRouting.valueForKey("routing")).valueForKeyPath ("part.billsOfMaterial"); log.debug("Number of possible routings for " + ((BillOfMaterial) aScheduledRouting.routing()).part().valueForKey("partDescription") +": " + scheduledRoutingBillsOfMaterial.count());
        return scheduledRoutingBillsOfMaterial;
    }

If the first one gets called, the second only returns one row.

Dave


On Mar 27, 2007, at 8:13 AM, Robert Walker wrote:

And you are absolutely sure you have two separate instances of NSArray and not two references to the same instance?

arr2 = arr1;

vs

arr2 = arr1.immutableClone();  or arr2 = new NSArray(arr1);

I'm sure it's not as simple as what is shown here, but within whatever complexity you have in your application I would first check to make sure that you really have two separate instances of your array.

If possible check either their object id's or check for equal references with something like:

if (arr1 == arr2) {
        // you have two references to the same array
}

On Mar 27, 2007, at 8:40 AM, David Avendasora wrote:

Okay, I have a odd behavior happening.

When I create and insert an object into my default editing context, and set all the various fields and relationships everything works just fine, but if I try to retrieve a list of all the possible objects for one of the relationships (to populate a pop-up button) all I get is the already selected one and not all of them. If I let the session expire then look at it again, the pop-up button has all the objects in it, just as I'd expect.

In a completely different part of the code, as part of the creation and population process, I filter a _different_ NSArray of objects of the same class and it is this filtering that is causing the problem, BUT it is done in a different class and I'm filtering a completely different NSArray.

Why would filtering one NSArray of objects cause a different NSArray of those same objects to be filtered as well??

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/ robertwalker1%40mac.com

This email sent to [EMAIL PROTECTED]

--
Robert Walker
[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/webobjects% 40avendasora.com

This email sent to [EMAIL PROTECTED]


--
Robert Walker
[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