Core Data Subentities and Subclasses
Core Data Subentities and Subclasses
- Subject: Core Data Subentities and Subclasses
- From: Jonathon Mah <email@hidden>
- Date: Tue, 10 Jan 2006 12:59:56 +1030
Hi all,
I'm having trouble understanding the relationship between Core Data
entity inheritance and class inheritance. I couldn't find any
documentation about it (on ADC or the list archives), so I did some
investigating and thought I should share the results.
For example, let's say there are four entities. (For clarity,
entities will be named EThing, and classes CThing.) ECar and ETruck
have EVehicle as their parent entity. EFerrari has ECar as its parent
entity.
EVehicle
(name, color)
/ \
ECar ETruck
(topGear) (wheelCount)
|
EFerrari
(topSpeed)
Now, EVehicle has its class set to CVehicle, a direct subclass of
NSManagedObject. I put together some questions and knocked up a test
app to try them out. Some I have answered myself.
Q1. Must ECar and ETruck's classes be a kind of CVehicle?
A1. No. It can be NSManagedObject, or a direct subclass of
NSManagedObject (e.g. CCar, or even CVehicle).
Q2. If ECar has its class set to NSManagedObject and I change its
name, will that call the -setName: method of CVehicle?
A2. No. It will only do so if ECar's class is set to a kind of CVehicle.
Q3. Is it "bad style" to have entity inheritance structured
differently to class inheritance?
Jonathon Mah
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden