Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SthrnCmfrtr

macrumors 6502
Original poster
Aug 20, 2007
310
0
Las Vegas, NV
I've only been coding a week, so please don't rape or pillage me. Also, I started with Objective-C and coding by hand, not futzing around in Interface Builder, so this is my first encounter with Cocoa Bindings.

My situation is that I have a Core Data entity with a "key" attribute and a "value" attribute. The idea is to have arbitrarily extensible metadata for each of the documents in my li'l project.

The problem is that I can't find out how to use Cocoa bindings to access the value for a given key.

For instance, each document has a "name" key (distinct from its filesystem name, natch) and then the value for that key. I would like to bind a NSTextField to the value of the key. The only way I can figure out to do it, though, is to create an instance variable and accessor method and then bind the NSTextField to that.

As a twist, I'm really aiming for getting and setting these variables from a separate nib with a separate windowcontroller.

I figure I'm missing something ridiculously obvious, but I've Googled and Cocoadev'd and developer.apple.com'ed for about three hours now and can't figure it out. Bindings are pretty opaque to me despite me reading the relevant developer docs a couple times.

Like I said -- I can do it, I just figure there's a better way that won't make grownup programmers cry.

P.S. I'm all for setting the binding programmatically rather than through Interface Builder, if I can.
P.P.S. I'm running Tiger and XCode 2.5, just in case that qualifies any responses.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.