If I understand your question, maybe you just need to do some initialization 
when the object is created.  Look at NSManagedObject:awakeFromInsert.  It's 
where you can do initialization (conditional if you wish, as long as you don't 
do something to disrupt the "insertion" process).  It's perfectly legal to 
populate relationships there too (ie: maybe every "Player" needs an array of 
"Things" when they're er..... hatched).


On Feb 4, 2010, at 8:04 PM, cocoa-dev-requ...@lists.apple.com wrote:

> Message: 11
> Date: Thu, 4 Feb 2010 19:13:36 -0600
> From: William Squires <wsqui...@satx.rr.com>
> Subject: Dumb question about Core Data
> To: cocoa-dev@lists.apple.com
> Message-ID: <67ea316e-47cc-44da-bf41-c1ebac1a9...@satx.rr.com>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
> 
> Let's say I have an entity, "Player" that has some attributes (Name,  
> Level, XP, FightStr, DefenseStr, etc...) for a role-playing game. How  
> do I pre-initialize an entity with known values, when their  
> properties are @dynamic? I need for a "blank" player to start out on  
> level 1 with 0 XP, 0 FightStr, and 0 DefenseStr, and a name of  
> "<Blank>". I can get Xcode to generate the class files (Player.m and  
> Player.h), but then I'm at a loss. I understand that the entity is  
> tied to the data store (SQLite 3 database, or XML, or a binary file),  
> but short of using XML and an ugly hack to pre-load the XML file, I  
> can't see a reasonable way to accomplish this seemingly common task.
> 
> 

------------------------------------------------------------------
John Bishop
Mulligan Software
<mailto:j...@mulligansoftware.com>
<http://www.mulligansoftware.com>
Twitter:  MulliganGolf

_______________________________________________

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

Reply via email to