• 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
Re: Core Data and pre loading objects (importing).
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data and pre loading objects (importing).


  • Subject: Re: Core Data and pre loading objects (importing).
  • From: Jerry Krinock <email@hidden>
  • Date: Tue, 15 Dec 2009 22:58:44 -0800

On 2009 Dec 12, at 08:34, Ben Packard wrote:

> NSManagedObject *player = [NSEntityDescription insertNewObjectForEntityForName:@"Player" inManagedObjectContext:[self managedObjectContext]];

The above is good.

> But what I want to do is use a tournament builder class from the original project that takes in a filepath and returns a Tournament, complete with all it's players, tables etc.  This function works well in the original project but when I try to use it in the core data project I get:
>
> Failed to call designated initializer on NSManagedObject class 'Tournament'

From NSManagedObject documentation, "If you instantiate a managed object directly, you must call the designated initializer (initWithEntity:insertIntoManagedObjectContext:)."

Or, -[NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext:], as you've used above, should do the same thing.  Some subtleties are explained in its documentation.

> How am I meant to load into core data a whole graph of objects (tournament and its constituent parts) that are returned from a function,

One at a time.  Just like you did with Players.  Do the same with all the Tables, all the Tournaments, etc.  You need to convert all these regular objects into managed objects.

> and where should I be putting the code?

wherever it feels good, probably after you read the file.  As long as it's running on the main thread.

_______________________________________________

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

References: 
 >Core Data and pre loading objects (importing). (From: Ben Packard <email@hidden>)

  • Prev by Date: Re: Managed Object with Transformable Attribute (C Struct)
  • Next by Date: Reg: Image editing using iPhone SDK
  • Previous by thread: Core Data and pre loading objects (importing).
  • Next by thread: NSUndoManager auto-grouping?
  • Index(es):
    • Date
    • Thread