Well, this works, but seems like I'm reinventing the wheel.
NSMutableArray<Finished> descendantFinisheds = new
NSMutableArray<Finished>();
for (Part aPart : descendantParts()) {
if (aPart instanceof Finished) {
descendantFinisheds.addObject((Finished) aPart);
}
}
And if I can force the casting of one object, why can't I force the
casting of the Array using (NSArray<Finished>) EOQual...?
Dave
On Jun 23, 2008, at 10:45 AM, David Avendasora wrote:
Hi all,
I am trying to take an array (decendentParts()) of "Part" objects
and filter only for the elements that are of the subclass "Finished".
Before Generics, I simply used: (yes, yes, I know I shouldn't be
using qualifierWithQualifierFormat - please let it go, this one time)
EOQualifier qual =
EOQualifier.qualifierWithQualifierFormat("partTypeId = 3", null);
NSArray descendantFinisheds =
EOQualifier.filteredArrayWithQualifier(descendantParts(), qual);
But now, with generics, the compiler complains that it can't convert
from "Part" to "Finished". Which I completely understand because
there's no way for the compiler to know that I just filtered for a
subclass and that all I'm going to get out of the filter process is
Finished objects so the statement is valid. As far as it's
concerned, I could be getting any subclass of "Part" back.
My question is, how do I filter so that the compiler will know that
the results of the filter truly are Finished objects?
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]