Re: Creating CoreData classes
Re: Creating CoreData classes
- Subject: Re: Creating CoreData classes
- From: Jim Correia <email@hidden>
- Date: Mon, 28 Dec 2009 00:07:31 -0500
On Dec 27, 2009, at 11:52 PM, Brian Bruinewoud wrote:
> If I've generated core data classes from my model, how do I use them to create new values?
> Currently I'm doing this:
>
> CDClass *cdObject = (CDClass *)[ NSEntityDescription insertNewObjectForEntityForName: @"CDClass" inManagedObjectContext: context ];
This is in fact the correct idiom for doing this.
> But I'm looking for something more like this:
>
> CDClass *cdObject = [ CDClass insertNewObjectInManagedObjectContext: context ];
You can use
CDClass *object = [[CDClass alloc] initWithEntity: entity insertIntoManagedObjectContext: context];
instead, but it is more verbose since you have to separately look up the entity by name.
- Jim
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden