• 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
[SOLVED] Re: dynamically adding NSTableColumns while using bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SOLVED] Re: dynamically adding NSTableColumns while using bindings


  • Subject: [SOLVED] Re: dynamically adding NSTableColumns while using bindings
  • From: "Paul Gribble" <email@hidden>
  • Date: Wed, 1 Aug 2007 20:57:03 -0400

Amazing ... it works. All I need to do inside my addColumn method is this:

- (IBAction)addColumn:(id)sender
{
    NSTableColumn *newColumn = [[[NSTableColumn alloc] init] autorelease];
    [newColumn bind:@"value" toObject:dataController withKeyPath:@"
arrangedObjects.newcol" options:nil];
    [dataTable addTableColumn: newColumn];
}

Nowhere else, in code, or in the nib, do I need to declare that I'm going to
be using "newcol" as the key path. It just knows. Now I will eventually have
to give each column a unique key path, like col2, col3, etc. but that's for
another day.

It handles non-equal #s of items. Here's what the data object looks like
with just one column of numbers:

data=({col1 = "1.1"; }, {col1 = "2.3"; }, {col1 = "3.4"; })

and then after I addColumn, and add only two (not three) values in the new
column:

data=(
    {col1 = "1.1"; newcol = "5.5"; },
    {col1 = "2.3"; newcol = "6.5"; },
    {col1 = "3.4"; }
)

great!
Thanks for the help




On 8/1/07, I. Savant <email@hidden> wrote:
>
> On Aug 1, 2007, at 5:11 PM, Paul Gribble wrote:
>
> > I have one NSArrayController in my nib file called dataController.
> > In IB I
> > have added one key to dataController list of keys, called "col1". the
> > dataController is then bound (by pointing and clicking in IB) to my
> > myDocument instance variable "data".
>
>    Ah, much easier. :-)
>
> > 1. create a new NSTableColumn and add it to the NSTableView. (I can
> > do this,
> > no prob).
>
>    Yes. Easy enough.
>
> > *2. create a new key for dataController called col2 (how do I do this
> > programmatically?)
>
>    Completely unnecessary. I never implicitly add keys to controllers
> myself. Maybe someone can tell me why I'm wrong in not doing so, but
> it's never hurt me before.
>
>    You may enjoy the following (imprecise) phrase: "If you bind it,
> it will find it.*"
>
>    * Unless it doesn't exist or is not KVC/KVO-compliant, then it
> will probably bitch at you.
>
> > 3. programmatically bind the new NSTableColumn to the
> > dataController new key
> > "col2" (I know how to do this from looking at mmalc's example
> > binding code)
> >
>    Also easy (when you know how).
>
>
> > Am I on the right track?
>
>    Why not try it and tell *us*? ;-)
>
> --
> I.S.
>
>
>
>


--
Paul L. Gribble, Ph.D.
Associate Professor
Dept. Psychology
University of Western Ontario
London, Ontario
Canada N6A 5C2
Tel. +1 519 661 2111 x82237
Fax. +1 519 661 3961
email@hidden
http://bubba.ssc.uwo.ca
_______________________________________________

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: [SOLVED] Re: dynamically adding NSTableColumns while using bindings
      • From: mmalc crawford <email@hidden>
    • Re: [SOLVED] Re: dynamically adding NSTableColumns while using bindings
      • From: "I. Savant" <email@hidden>
    • Re: [SOLVED] Re: dynamically adding NSTableColumns while using bindings
      • From: "I. Savant" <email@hidden>
References: 
 >dynamically adding NSTableColumns while using bindings (From: "Paul Gribble" <email@hidden>)
 >Re: dynamically adding NSTableColumns while using bindings (From: "Sean McBride" <email@hidden>)
 >Re: dynamically adding NSTableColumns while using bindings (From: "Paul Gribble" <email@hidden>)
 >Re: dynamically adding NSTableColumns while using bindings (From: "I. Savant" <email@hidden>)

  • Prev by Date: Re: How to be notified of scrolling an NSTableView
  • Next by Date: Re: [SOLVED] Re: dynamically adding NSTableColumns while using bindings
  • Previous by thread: Re: dynamically adding NSTableColumns while using bindings
  • Next by thread: Re: [SOLVED] Re: dynamically adding NSTableColumns while using bindings
  • Index(es):
    • Date
    • Thread