Bindings in Xcode 4.0


#1

I’m having trouble with the example on page 114 in the book. Everything seems to match up right up until figure 7.3 Bind Value of Slider to fido.

I’ve selected the check box next to the Bind to and selected AppController. However, under Model Key Path, when i first came in, it was filled in with self and had a red exclamation point. I tried changing it to fido, that changed the exclamation point to black, and i tried building and running the application. It threw a exception as follows:

2011-07-09 21:02:47.709 KVCFun[7188:903] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Cannot create double from object <_NSControllerObjectProxy: 0x100133fa0> of class _NSControllerObjectProxy’

I’m not clear what i did wrong.

Any assistance would be welcome.


#2

Hi,

I’ve had the same problem for one week and I seek a solution. In the documentation “Mac OS 10.6 Core Library > General > Cocoa Application Tutorial Using Bindings”, I try it but have the same trouble (I’ll test it once again).


#3

I’m having the same problem, and it’s been over a month since this was first reported. I guess I’m disappointed that no one has seen fit to address this (Aaron?). It appears the problem is that the mechanism expects a double and is getting fido, an integer?

Hmmm, maybe make fido a double?

I’ll post again my results after I try it…

Edit: changing fido to a double doesn’t help. I’m flummoxed!


#4

Well, I got it to work, but I don’t understand what happened. I had self.fido in the “Model Key Path” field in the bindings, but it had been cleared; when I re-typed it in the field and tried again, the code worked fine.

Very strange!


#5

I ran into the same error going through the Images and Mouse Events (Chapter 18) of Cocoa Programming for Mac OS X (4th Edition)
Turns out I had accidentally bound the Horizontal Slider to the Shared User Defaults Controller with the Controller Key set to the default, values. This is why, I assume, the conversion from an object to a double was throwing an exception. What was masking this problem was I had bound the child view of Horizontal Slider, Slider Cell, to stretchView.opacity which is a float, so my binding looked correct in IB.
Binding the Horizontal Slider view to Drawing Fun App Delegate’s stretchView.opacity cleared up the exception.
HTH