In an Xcode Document app: why do I need to call the MyDocument method twice?

I followed Chapter 8 of Hilgassa to implement the RaiseMan application there. I then decided to follow the same process to implement the code for the exercise in a Cocoa programming class that I am assuming, but after building and running, I received the following very cryptic error message.

Unable to create BOOL from object <_NSControllerObjectProxy: 0x100460e30> of class _NSControllerObjectProxy

I have no idea what this error message means. Doing a Google search brought up some hits, but their means seemed to be to do what I was already doing.

I have looked at all the connections and assignments I created in Interface Builder and nothing looks clearly wrong.

So, I went into the debugger and set a breakpoint inside the init method of the MyDocument class, and it gets called twice. How could this happen? What should I be looking for so the init method is called twice? The stack trace shows that init is called by system functions that we didn't write ourselves.

For comparison, I went back to the project next to Chapter 8 of Hillegass and set a breakpoint inside the init method of the MyDocument class and it gets called once (which is to be expected).

+2


source to share


2 answers


Cannot be created BOOL

from <_NSControllerObjectProxy: 0x100460e30>

class object _NSControllerObjectProxy

It looks like you have bound a property BOOL

to a controller and have not provided a path to the key part of the model. Chances are you have linked one of the built-in Cocoa view class bindings such as enabled

or editable

.



Review your nib for presentations whose enabled

or editable

you're tied up, and make sure that they are all linked to the correct path of the model key.

+6


source


I just stumbled upon this myself. And then I remembered that I had seen something strange before, the meaning of which at that time did not strike me. What is it in my XIB file, in addition to the "File Owner" object (which actually represents the document in the XIB file) was the "My Document" object. I have no idea how this happened, but I removed it in IB, recompiled and presto, [MyDocument init] only gets it once.



+1


source







All Articles