Creating Subclass in Core Data

2009-02-22 Thread Paul Franz

I have a simple class hierarchy defined in Model for the Core Data Entity:

Class: AbstractClass (Abstract Class is checked as abstract
Parent Class: None
Attributes:
   Name
   Children

Class: Class1
Parent Class: AbstractClass
Attributes: None

Class: Class2
Parent Class: AbstractClass
Attributes:
   Description
   Cost

How do I create a subclass of Class1 or Class2 instead of the abstract class 
AbstractClass?


I have created a NSTreeController in IB. The Attributes tab for the 
NSTreeController, the Key Paths (Children) is set to Children and Object 
Controller (Mode) is set to Entity with the Entity Name is set to 
AbtractClass. I have a NSOutlineView which is bound to this NSTreeController. 
And a New button to create a new entity is bound to the add method of the 
NSTreeController and a New Child button to create a new child is bound to the 
addChild method of the NSTreeController. It seems to work. But I have no idea 
what types of entities are being created. My assumption is that they are of type 
AbstractClass.


Paul Franz
___

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


Re: Creating Subclass in Core Data

2009-02-22 Thread Volker in Lists

Hi Paul,

I recommend not use the add: / addChild: methods of the  
TreeController, but create yur own methods for that. In each  
instantiate an object of the entitytype you want as parent/child. See http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CoreData/Articles/cdCreateMOs.html#/ 
/apple_ref/doc/uid/TP40001654 for how to create objects in code. Set  
the proper parent objects , that is nil for parents and the parent  
entity for the children.


I have the same solution in a couple of apps with exactly the same  
structure and needs as I gather you have.


Cheers,
Volker

Am 22.02.2009 um 20:19 schrieb Paul Franz:

I have a simple class hierarchy defined in Model for the Core Data  
Entity:


Class: AbstractClass (Abstract Class is checked as abstract
Parent Class: None
Attributes:
  Name
  Children

Class: Class1
Parent Class: AbstractClass
Attributes: None

Class: Class2
Parent Class: AbstractClass
Attributes:
  Description
  Cost

How do I create a subclass of Class1 or Class2 instead of the  
abstract class AbstractClass?


I have created a NSTreeController in IB. The Attributes tab for the  
NSTreeController, the Key Paths (Children) is set to Children and  
Object Controller (Mode) is set to Entity with the Entity Name is  
set to AbtractClass. I have a NSOutlineView which is bound to this  
NSTreeController. And a New button to create a new entity is bound  
to the add method of the NSTreeController and a New Child button  
to create a new child is bound to the addChild method of the  
NSTreeController. It seems to work. But I have no idea what types of  
entities are being created. My assumption is that they are of type  
AbstractClass.


Paul Franz
___

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/volker_lists%40ecoobs.de

This email sent to volker_li...@ecoobs.de


___

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