• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem using custom entity class with subclasses NSArrayController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Problem using custom entity class with subclasses NSArrayController
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: Re: NSTreeController: do leaf and non-leaf nodes have to be of the same class?
  • Next by Date: Re: How do I find out if a process is running if I have the process Name?
  • Previous by thread: Re: coredata sql store on WebDAV mounted volume
  • Next by thread: Re: Problem using custom entity class with subclasses NSArrayController
  • Index(es):
    • Date
    • Thread