Core Data and pre loading objects (importing).
Core Data and pre loading objects (importing).
- Subject: Core Data and pre loading objects (importing).
- From: Ben Packard <email@hidden>
- Date: Sat, 12 Dec 2009 11:34:28 -0500
Hi, I am pretty new to cocoa so thanks for being patient...
I have spent some time building a command line tool that reads a .txt file saved locally by an online poker client. This file contains data on my own playing history. I have a chunky method that dissects this file and creates different objects of type Tournament, Table, Player, Hand, Card etc and works well.
Having accomplished this, I set about trying to build a core data app to display the data. I have replicated my model exactly as it is in the original project and successfully set bindings etc. For example, I can create, edit and remove players.
But I am entirely stuck on how to join the two projects. All I really want to do is use the method I already have to populate the core data application, but despite hours of searching I don't know where or how to start. I have been able to programmatically create new players using:
NSManagedObject *player = [NSEntityDescription insertNewObjectForEntityForName:@"Player" inManagedObjectContext:[self managedObjectContext]];
I have put this in the init of MyDocument and it creates and dsiplays the player (via the binding) as expected. 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'
All of my classes have created by xcode and inherit from NSManagedObject. I have then replaced the contents of each .m file with the original classes.
I know I'm doing something horribly wrong here, so my question is this...
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, and where should I be putting the code?
Thanks in advance for any help.
Ben_______________________________________________
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