• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSArrayController bound to an array of strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArrayController bound to an array of strings


  • Subject: Re: NSArrayController bound to an array of strings
  • From: "Chris Suter" <email@hidden>
  • Date: Mon, 17 Nov 2008 05:45:30 +1100

On Mon, Nov 17, 2008 at 4:45 AM, Meik Schuetz <email@hidden> wrote:
> Dear all,
> If have seen lots of examples in which a NSTableView is bound to an
> NSArrayController which is bound to an array of entity objects, having
> various properties. However I am now trying to bind a table column to an
> array of strings and I don't seem to get this working. The string contents
> show up correctly, but when I try to modify an existing item, or add a new
> item, I get the error
>
> Error setting value for key path  of object  (from bound object
> <NSTableColumn: 0x10bb40>(null)): [<NSCFString 0xa0609328>
> setValue:forUndefinedKey:]: this class is not key value coding-compliant for
> the key .
>
> I got the NSArrayController bound to the NSMutableArray property of my
> AppController class. I set the class to NSMutableString (also tries
> NSString). The NSTableView is bound to the NSArrayController, as well as the
> table column.
>
> Do I really need to create a class which only contains a string property to
> get this working, or is there any trick that I don't know about.

The only trick I can think of is to use "string" as the model key and
then, because NSString doesn't have a "string" method, you need to add
a category method to NSString:

- (NSString *)string
{
  return self;
}

Having said that, it's not a particularly nice way of doing things and
you need to make sure you use mutable strings (which you might not
need otherwise). If I were you, I'd create a new object. You might
find that you want to add more columns to the table in future.

-- Chris
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSArrayController bound to an array of strings
      • From: Andy Lee <email@hidden>
References: 
 >NSArrayController bound to an array of strings (From: Meik Schuetz <email@hidden>)

  • Prev by Date: NSView positioning problems
  • Next by Date: Re: NSView positioning problems
  • Previous by thread: NSArrayController bound to an array of strings
  • Next by thread: Re: NSArrayController bound to an array of strings
  • Index(es):
    • Date
    • Thread