Hi all,

Let me start off by saying, I am new to cocoa and objective c programming.
Any help is greatly appreciated.

The Error:
"Unacceptable type of value for to-many relationship: property = "id";
desired type = NSSet; given type = NSCFString; value = 1001."

My main goal here is to have core data application that implements an
NSBrowser view; this being a hierarchic view of entities which I call
categories, such as...

Category -> SubCategories -> SubCategories , etc.

The sub categories selected should be based on the previous columns selected
category, obviously.

After googling up a previous post here, I followed along and set up an
entity.

I have an entity defined, called Category which has:

+ Attribute: "name"
    Type: (String)

+ Relationship: parentID
    Destination: "Category"

+ Relationship: id
    Destination: "Category"
    To-Many Relationship
    Inverse: parentID

My MainMenu.nib is as follows:

+  NSTreeController
       Attributes
           Mode: Entity
           Entity Name: "Category"
           Child Key Path: "id"
       Binding
           Parameters
               managedObjectContext
                   Bind To: MyApplication_AppDelegate
                   Model Key Path: managedObjectContext

 + NSBrowser
       Bindings
           Browser Content
               content
                   Bind To: NSTreeController
                   Controller Key: arrangedObjects
                   Model Key Path: Leave Blank
               contentValues
                   Bind To: NSTreeController
                   Controller Key: arrangedObjects
                   Model Key Path: "name"
               selectionIndexPaths
                   Bind To: NSTreeController
                   Controller Key: selectionIndexPaths
                   Model Key Path: Leave Blank

After I do some parsing of XML, I am programmatically creating my category
entities and supplying core data with the values for my keys...

NSManagedObject *category = [NSEntityDescription
insertNewObjectForEntityForName:@"Category" inManagedObjectContext:[self
managedObjectContext]];
..
[category setValue:[childNode stringValue] forKey:@"name"];
[category setValue:[childNode stringValue] forKey:@"id"];
[category setValue:[childNode stringValue] forKey:@"parentID"];

I realize that I'm passing a string, but according to the error, it wants an
NSSet?  How do I fix this?
     
I also read something about subclassing NSCell and adding the following
methods:

- (id)objectValue
- (void)setObjectValue:(id)anObject

However, this did not work for me.
                   
Regards,
Mark.


_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to