On Mon, Apr 26, 2010 at 10:43 AM, vincent habchi <vi...@macports.org> wrote: > I need to create a short-lived NSManagedObject; ideally, I'd want it not to > be inserted in the Core Data underlying framework, because I need it only > during the display of an auxiliary window, and I don't want it saved anyway. > I've tried a simple alloc, an alloc and init, but to no avail: It seems to > create only the proxy object. Is there a way to do that? > > Thanks, > Vincent_______________________________________________
What you want to do, probably, is create an object that doesn't belong to a context (the context is what ends up saving your object to a data store). You should be able to do something like this: // assuming your app delegate contains the "managedObjectModel" method, which // the standard Xcode-generated CoreData app typically does NSManagedObjectModel *managedObjectModel = [[NSApplication delegate] managedObjectModel]; NSEntityDescription *entity = [[managedObjectModel entitiesByName] @"MyEntity"]; id obj = [[NSManagedObject alloc] initWithEntity:entity insertIntoManagedObjectContext:nil]; BTW the docs for NSManagedObject clearly state that "initWithEntity:insertIntoManagedObjectContext:" is the designated initializer to use for creating instances, and that you shouldn't just call "init". -- // jack // http://nuthole.com // http://learncocoa.org _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com