re: Is it possible to override a property in an Entity subclass in CoreData?
re: Is it possible to override a property in an Entity subclass in CoreData?
- Subject: re: Is it possible to override a property in an Entity subclass in CoreData?
- From: Ben Trumbull <email@hidden>
- Date: Tue, 19 Feb 2008 21:45:37 -0800
I would like to emulate property type overloading in CoreData. The
model might look something like:
FooEntity (Abstract) {prop1:string, prop2 : UNKNOWN}
BarEntity (inherits FooEntity) {prop2 : int}
BazEntity (inherits FooEntity) {prop2 : double}
Core Data doesn't support this.
If you eliminate the property on FooEntity, you could do separate
queries using -setIncludesSubentities: to fetch exactly BarEntity and
BazEntity types and union the results. Your managed object classes
could all support accessors for 'prop2' (e.g. a protocol, etc) so
dropping the property from the abstract entity wouldn't be apparent
to the code.
If you didn't need to search on the property, you could use the
transformable attribute type, and have something completely different
in each row, let alone subentity.
The CoreData fetch could then translate the
original predicate ("prop1=='test' && prop2 == 10") into a query into
the appropriate column comparisons
How would we know which prop2 the prop2 in the predicate refers to ?
The columns have different types, and we consider strong typing a feature.
Then there's the problem that integers and doubles do not compare or
cast with perfect fidelity.
long long x = (long long)0xDEADBEEFDEADBEEFll;
double y = (double)x;
long long z = (long long)y;
And z != x. Ouch. Now what ?
How does your code know what it's going to get back and how to use it
without loss of precision ?
Why do you want to conflate a column with different types anyway ?
--
-Ben
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden