Re: Best Way® to test for existence of a relationship
Re: Best Way® to test for existence of a relationship
- Subject: Re: Best Way® to test for existence of a relationship
- From: Alexander Spohr <email@hidden>
- Date: Mon, 7 Apr 2008 17:55:36 +0200
Fetch only ManufacturedParts.
Don’t use the relationship to Parts (if that’s what you do) to get the
NSArray.
Either create a relationship to ManufacturedParts or fetch them using
a qualifier.
Iterating over a mixed NSArray wanting only one special class is bad
design. Filter it before you use it for such a task.
atze
Am 07.04.2008 um 15:12 schrieb David Avendasora:
Hi all,
This is more of a Java question than a WO-specific one
I have an Inheritance structure in my app:
Part (abstract Superclass)
RawMaterial (subclass of Part)
ManufacturedPart (subclass of Part)
I have an NSArray of Parts that could be, RawMaterial instances,
ManufacturedPart instances, or most likely, a mixture of the two.
I want to iterate through the Array and get the contents of the
Part.billsOfMaterial() (toMany) relationship. The problem is that
while ManufacturedParts have this relationship, RawMaterials do not.
Right now, I'm using a try-catch block that catches the exception on
RawMaterial.billsOfMaterial() and just ignores it.
I could also add a billsOfMaterial() method to the RawMaterial class
that simply returns NSArray.emptyArray.
Is one way better than the other for any reason?
Thanks,
Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
---
Alexander Spohr
Freeport & Soliversum
Fax: +49 40 303 757 99
Web: http://www.freeport.de/
Box: http://dropbox.letsfile.com/02145299-4347-4671-aab9-1d3004eac51d
---
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden