“[something copyWithZone:]: unrecognized selector sent to instance” when using Bindings / Core Data

前端 未结 8 1694
情深已故
情深已故 2020-12-28 13:49

(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

8条回答
  •  别那么骄傲
    2020-12-28 14:24

    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%.

    1. Core-Data objects cannot implement copyWithZone: - this causes the crash

    2. When a tableview is populated using Bindings, it tries to copy the values of the objects in the NSArrayController to render each Column

    3. ...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.

提交回复
热议问题