NSBrowser, NSTreeController and Core Data
NSBrowser, NSTreeController and Core Data
- Subject: NSBrowser, NSTreeController and Core Data
- From: Mark Scardigno <email@hidden>
- Date: Mon, 13 Oct 2008 11:58:20 -0400
- Thread-topic: NSBrowser, NSTreeController and Core Data
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 (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