views:

753

answers:

5

I am new to Cocoa and I am working my way through the examples in Hillegass's book 'Cocoa programming for Mac OS-X'. There have been a couple of occasions when a sample application I have been working through starts up and I get a message such as :

2009-03-11 00:39:19.167 CarLot[7517:10b] Cannot create NSData from object <_NSControllerObjectProxy: 0x188bf0> of class _NSControllerObjectProxy

The only way I have found of solving an issue like this is to painstakingly go through all of the bindings and attributes in the interface builder to see where I have missed some configuration - which all takes time!

Is there any more efficient way to determine what the problem is from the error message? Are there any debugging techniques you can use to track down problems like these?

+1  A: 

I'm not sure that there is a way to get a summary of the bindings and attributes that you have setup other than in Interface Builder itself. As far as I know that is the only gui that shows this information. You can try running your application in the debugger and breaking on exceptions (-[NSException raise]) to see if you can at least track down which object is giving you this error, which might help you locate the bad connection in IB.

If your application is small enough and builds fast, and you are just starting out using IB and bindings, I would suggest that you make one connection and test it to see if it works and then move on to the next. That way you will know which connection or attribute is causing the problems.

I hope someone has a better answer than this, but as far as I know there isn't a tool to verify and pin-point IB connection problems.

Evan
+2  A: 

This Article talks very briefly about this.

Basically, it states that you can look in the Xib files to figure out a bit more quickly what bindings you have set in your app.

Hope that helps!

Aaron
A: 

What if you do the bindings programmatically instead of doing it in interfacebuilder?

To do this you have to use this method of NSObject:

- (void)bind:(NSString *)binding toObject:(id)observableController withKeyPath:(NSString *)keyPath options:(NSDictionary *)options

Earl Claridad
A: 

One thing that I didn't notice at first was that if you look at the connections inspector for an object, it shows a nice list of everything it's bound to, and if you hover over an item, it highlights its corresponding element.

That's nice for when you've bound something to a Table Column yet again.

+2  A: 

There's a wonderful article on Apple's Dev Site on troubleshooting bindings.

http://developer.apple.com/mac/library/documentation/cocoa/conceptual/CocoaBindings/Concepts/Troubleshooting.html

The key take-away? There's a setting called NSBindingDebugLogLevel that you can use to get debug information.

Two ways to set it:

1 - Permanently in your defaults

defaults write com.yourdomain.yourapplication NSBindingDebugLogLevel 1

2 - Pass it as a parameter when you debug

path/to/your/app -NSBindingDebugLogLevel 1

Michael Bishop