Subclassing NSManagedObject
Subclassing NSManagedObject
- Subject: Subclassing NSManagedObject
- From: David Alter <email@hidden>
- Date: Tue, 6 Jun 2006 21:20:31 -0700
I'm using Core Data with a persistent data store. I need to subclass
a NSManagedObject for some of the things I want to do. Before I
subclassed I had things working using NSManagedObject. Now that I
have created a subclass things are no longer working.
I can load up data just fine. The first time the application launches
it initializes the persistent data store with some data collected
from an external source. This data appears in a NSTableView that I
have connected with bindings. That all works great.
The second time I launch the application it reads the data store from
disk and creates an object for each record saved to disk, but does
not set the values for that record. So now my NSTableView has lots of
rows with no data in them.
I'm not sure what I'm missing here. When I subclassed NSManagedObject
I changed the following...
1) In the object model I changed the entity to my class name and not
NSManagedObject.
2) In my nib I made my control object an entity with the name I used
in my Object Model
To debug I have added the method "- (id)initWithEntity:
(NSEntityDescription *)entity insertIntoManagedObjectContext:
(NSManagedObjectContext *)context" to my subclass of NSManagedObject.
I know this is not recommended but I wanted to make sure my class was
getting created. It is initializing my subclass but none of my set
methods are being called. I'm not clear on how my objects should be
initialized with the data from disk. I assumed that it would use set
methods and key value coding to set the data.
Could someone please let me know what I'm missing here? Or, some
ideas of what I can try to see what is going on.
Thanks for the help
-dave
_______________________________________________
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