(self asking and self-answering because I spent hours on the web looking for this, and most of the resources all say \"I solved it in the end\" without giving an explanation
As a hint to avoid any kind of problems with the binding one can convert the NSManagedObject
into NSDictionary
while populating the controllers with:[object dictionaryWithValuesForKeys:[[object entity] attributeKeys]]
, it is a lot easier to connect and debug :-)
Thanks for the pointer by the way!
Accidentally faced with this issue.
After a little investigation I found out that the reason was wrong cocoa binding option set on NSTextField
-cell object.
The problem was fixed by switch the binding off.
I would also like to post here because I had a similar issue with the same type of thing
empty defined object:
Wrong code:
@property (nonatomic, copy, readwrite) MSender * sender;
this should trow a compile error because with reference counting Xcode has no idea how to copy my object. Instead it fails at run time...
Write code:
@property (nonatomic, strong, readwrite) MSender * sender;
Hope it helps someone.
I encountered this error when I tried to implement a master-detail binding. Something analogous to Department / Employee. I tried to bind an arrayController to "selection.employees" of Department and got:
-[Employee copyWithZone:]: unrecognized selector sent to instance
Turned out the employees relationship was not set to to-many, as intended, but to-one. Once I corrected this, all was well.
Turns out ALL the above are needed to trigger this, and XCode is allowing you to do something that's wrong in 99.9% of situations, if not 100%.
Core-Data objects cannot implement copyWithZone: - this causes the crash
When a tableview is populated using Bindings, it tries to copy the values of the objects in the NSArrayController to render each Column
...but if you fail to specify the Column binding fully (Xcode allows you to half specify it), then tableview tries the "copy" on the objects instead of their values
The bug in my bindings: I had specified that a Table Column had a "value" with:
Controller Key = "arrangedObjects" Model Key Path = (blank)
(this is a bug in XCode4 autocomplete - it will delete the ModelKeyPath field sometimes when you tab away too quickly)
Finish typing-in the binding, e.g.:
Model Key Path = "value"
...and everything works again.
I also had a similar problem and it came from calling a ProxyObject rather than the actual object from an array controller.
For example:
MYEntity *entity = EntityController.selection;
NSString *property = entity.property; // <--- causes the error
but
MYEntity *entity = EntityController.selectedObjects firstObject]; // <--- fixes the error
NSString *property = entity.property;