Problem using custom entity class with subclasses NSArrayController
Problem using custom entity class with subclasses NSArrayController
- Subject: Problem using custom entity class with subclasses NSArrayController
- From: David Groulx <email@hidden>
- Date: Thu, 18 May 2006 14:27:28 -0600
I'm writing a program with a NSTableView to display several folders,
where each folder is represented internally as a Core Data entity.
The user adds folders to the list by browsing to the folder they want
and adding that folder manually. To do this, I subclassed
NSArrayController to override its -(IBAction)add: method. Within
that method I create a new entity with the code:
NSManagedObjectContext* moc =
[[NSApp delegate] managedObjectContext];
NSManagedObjectModel* mom =
[[moc persistentStoreCoordinator] managedObjectModel];
NSEntityDescription* entity =
[[mom entitiesByName] objectForKey:@"Uda"];
NSManagedObject* newUda =
[[NSManagedObject alloc] initWithEntity:entity
insertIntoManagedObjectContext:moc];
[self addObject:newUda];
and that worked fine. Now I need to use a custom class for this
entity, but I get the
error
Attempt to create an NSManagedObject that does NOT correspond to the
proper Class from the NSEntityDescription.
I've fixed this problem by replacing NSManagedObject with the name of
my new entity class, but this seems like I'm ruining the abstraction
that my program sees between an entity and it's concrete
representation. Is there a more dynamic way to create a new managed
object represented by a custom class here? Thanks for any feed back
David Groulx
_______________________________________________
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