NSTableView of strings

Chris Hanson cmh at mac.com
Sun Dec 9 02:53:52 PST 2007


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



More information about the MacOSX-dev mailing list