Women in Technology

Hear us Roar



Article:
  The Cocoa Controller Layer
Subject:   What about "separate" data
Date:   2004-07-17 08:28:32
From:   swoodnj
Forgive me if I'm missing something...I got excited when learning about the bindings, I've been working on an extensive database app and have been writing lots of glue code. I understand the concepts and have a demo or two working, but I don't understand how I can use this with external data, in my case a postgresql database. Let's say I bind an Add button to add:, how can I grab the data for my own use? Am I missing something obvious here? I can see where it might be useful with a document based app and NSCoder, but not for my purposes...
Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • What about "separate" data
    2004-10-08 13:35:11  scottellsworth [View]

    There are a couple of ways to handle this.

    Likely the easiest is to create an NSArray subclass that has hooks on the accessors. When a new row is added in the interface, eventually, a new item will be added to your NSArray subclass. You can then "do what is appropriate" to get the user entered data, enter it in a database, etc. You can get as fancy as need be - watch for selection changes before commit, update the row with generated keys, etc.

    Just make sure that if you programatically change any value in your NSArray behind the back of the controller, that you do one of the things that tells KVO that you made a change.

    Scott