Core Data: Accessing a "value" for a given "key"

Discussion in 'Mac Programming' started by SthrnCmfrtr, Jun 4, 2008.

  1. SthrnCmfrtr macrumors 6502

    Joined:
    Aug 20, 2007
    Location:
    Las Vegas, NV
    #1
    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.
     
  2. SthrnCmfrtr thread starter macrumors 6502

    Joined:
    Aug 20, 2007
    Location:
    Las Vegas, NV
    #2
    Hmm. No one has any ideas? I'm a bit surprised. It seems like it should be basic functionality.
     

Share This Page