NSTableView of strings

  • I'm trying to set up a list of strings, which the user can edit in an
    NSTableView. I can bind it to an NSArray which contains
    NSMutableStrings. This displays the list fine, but when I try to edit
    one of the strings, it fails. There doesn't seem to be a key that
    works to both read and write the value of an NSMutableString. There's
    a setString: but no string, for example. (Displaying works fine with
    no key at all.)

    I'm no Cocoa bindings guru, so I'm probably missing something.

    (The same window has a multi-column NSTableView which is bound to a
    more complex data structure. This works fine, because my data has
    setters and getters for each column.)

    David Dunham    A Sharp, LLC
    Voice/Fax: 206 783 7404    http://a-sharp.com
    "People seem to misinterpret complexity as sophistication" -- Niklaus
    Wirth
  • It's exctly as you say: you cant use a NS(Mutable)String for mutable
    value binding. You have to wrap it in an object such as
    NSMutableDictionary. (Well you can define a -string accessor in an
    NSString category, but I wouldn't recommend it).

    Christiaan

    On 9 Dec 2007, at 1:51 AM, David Dunham wrote:

    > I'm trying to set up a list of strings, which the user can edit in
    > an NSTableView. I can bind it to an NSArray which contains
    > NSMutableStrings. This displays the list fine, but when I try to
    > edit one of the strings, it fails. There doesn't seem to be a key
    > that works to both read and write the value of an NSMutableString.
    > There's a setString: but no string, for example. (Displaying works
    > fine with no key at all.)
    >
    > I'm no Cocoa bindings guru, so I'm probably missing something.
    >
    > (The same window has a multi-column NSTableView which is bound to a
    > more complex data structure. This works fine, because my data has
    > setters and getters for each column.)
    >
    > David Dunham    A Sharp, LLC
    > Voice/Fax: 206 783 7404    http://a-sharp.com
    > "People seem to misinterpret complexity as sophistication" --
    > Niklaus Wirth
    >
  • On Dec 8, 2007, at 4:51 PM, David Dunham wrote:

    > I'm trying to set up a list of strings, which the user can edit in
    > an NSTableView. I can bind it to an NSArray which contains
    > NSMutableStrings. This displays the list fine, but when I try to
    > edit one of the strings, it fails. There doesn't seem to be a key
    > that works to both read and write the value of an NSMutableString.
    > There's a setString: but no string, for example. (Displaying works
    > fine with no key at all.)
    >
    > I'm no Cocoa bindings guru, so I'm probably missing something.
    >
    > (The same window has a multi-column NSTableView which is bound to a
    > more complex data structure. This works fine, because my data has
    > setters and getters for each column.)

    Think of it this way:  A table view allows the user to interact with a
    collection of objects, one property per column.  This is as true for
    your single-column table view as it is for your multi-column table
    view.  Thus rather than trying to bind the table view directly to a
    collection of strings, you should bind it to a collection of objects
    that have some string property.

      -- Chris
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today