views:

183

answers:

3

I am creating an App and when I run it I check the Debug Pane, I am getting these errors Inside the Console:

2009-05-27 07:18:03.852 Spark[1228:10b] [ valueForUndefinedKey:]: the entity Projects is not key value coding-compliant for the key notes.

2009-05-27 07:18:09.029 Spark[1228:10b] Error setting value for key path selectionIndexPaths of object [entity: Projects] (from bound object with object ID 726 in Nib named MainMenu.nib): [ valueForUndefinedKey:]: the entity Projects is not key value coding-compliant for the key notes.

It only happens when I bind a text fields value to the NSTreeController's selection and Controller Key 'Notes', I also notice that when I try and edit the text field in the App the Outline View freezes(this is when the above error shows in console). How can I fix this Have I not binded the Text Field correctly, here is a picture of the Bindings for the text field: http://snapplr.com/840y

Entity Diagram

http://snapplr.com/vqc9

The NEW Error

**2009-05-27 18:37:41.661 Spark[3957:10b] Unacceptable type of value for attribute: property = "notes"; desired type = NSString; given type = NSConcreteAttributedString; value = Alpha Nine Zeta{
    NSColor = NSNamedColorSpace System textColor;
    NSFont = "MarkerFelt-Thin 16.00 pt. P [] (0x001a7190) fobj=0x00146ef0, spc=4.00";
    NSOriginalFont = "MarkerFelt-Thin 16.00 pt. P [] (0x001a7190) fobj=0x00146ef0, spc=4.00";
    NSParagraphStyle = Alignment 3, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (
    28L,
    56L,
    84L,
    112L,
    140L,
    168L,
    196L,
    224L,
    252L,
    280L,
    308L,
    336L
), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0.05, HeaderLevel 0;
}.**
+1  A: 

If a project is selected in your outline view, the text field tries to get the value notes from the 'selected' treecontroller item, which is a project. Since a Projects entity has no notes attribute, the KVO throws an exception.

Deselect the binding option 'Raises for Not Applicable Keys' in the 'value' binding of the text field.

cocoafan
Thanks, that has fixed part of the Problem, but when I change the text in the text field when it is selected the Outline View Freezes, and Console gives me this error. [See First Post Edit For Error]
Joshua
cocoafan: All that did was mask the error, which is that he's binding to the wrong entities.
Peter Hosey
Peter Hosey: I think he wants to display all projects at the top level in a tree acting as folders for the tasks. The NSTreeController can contain both, Projects and Tasks.
cocoafan
A: 

Second Error:

In the Text Field's attributes, do you have the Rich Text option selected? it looks like it is sending an NSAttributedString to the the Notes property, which expects an NSString.

Turn this option off if it is set.

Abizern
Yes, that was it Thanks! Unfortunately I can't tick two answers, would you mind if I tick cocoafan's answer because he has less points and answered first?
Joshua
Sure. Glad to help.
Abizern
+1  A: 

You've bound the text field to a Projects's notes, but in your model, only Taskses have notes. If you meant for Projectses to have notes, you need to add that property to the Projects entity; if you meant to bind to the Taskses, then you need to change the model key path, probably to children.notes.

(Related: Those entity names should really be singular.)

As for the new error: Text fields can't display styled text, only plain text. Make a text view instead.

Peter Hosey
Sorry, Abizern and Cocoafan Beat you to it.
Joshua
Not exactly. They correctly identified the problems, but gave different solutions (and cocoafan's was even wrong, as it masked the problem but did not solve it).
Peter Hosey