Hi everybody,
I have a problem with a bound property of a custom view. The property is bound to an NSArrayController for a core-data entity.
Here's the problem:
In my view, I draw several rectangles. The positions of these rectangles are saved in an entity in core data (as NSValue wrapped NSRects). The rectangles are draggable, and when I drag a rectangle, I want the entity to be updated to the new position. But I can’t find out how to bind the arrayController back to the view.
Here is how everything is connected:
I have a windowController with outlets to the view and the arrayController.
The arrayController is bound to the managedObjectContext of the windowController and therefore to my core-data model. (That binding and the binding to the entity are established in Interface Builder)
The view is bound to the arrayController with an ivar „rectangleValuesArray“
That last binding is established in the windowController using:
[connectionsView bind:@"rectangleValuesArray"
toObject:elementsArrayController
withKeyPath:@"arrangedObjects.rectangleValue"
options:nil];
That works so far.
Now I tried to establish the binding in the other direction with:
[elementsArrayController bind:@"arrangedObjects.rectangleValue"
toObject:connectionsView
withKeyPath:@"rectangleValuesArray"
options:nil];
Now when I change my ivar, the Entity should be updated (right?). But that doesn’t work - I get that from the console:
Cocoa Bindings: Error setting value for bound property arrangedObjects.rectangleValue of object <NSArrayController: 0x200027100>[entity: Element, number of selected objects: 1]: [<NSArrayController 0x200027100> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key arrangedObjects.rectangleValue.
What am I getting wrong here? Please, somebody help?
Simon