Re: Setting subclass of NSArrayController as data source programmatically
Re: Setting subclass of NSArrayController as data source programmatically
- Subject: Re: Setting subclass of NSArrayController as data source programmatically
- From: Christian Schneider <email@hidden>
- Date: Thu, 28 Apr 2005 16:56:34 +0200
Hi list,
found where I was wrong. I have to bind the table and the columns to
the array controller before I set the controller as data source;
though why that is so, I don't have any idea.
chris
On 4/28/05, Christian Schneider <email@hidden> wrote:
> Hi list,
>
> I have a subclass of NSArrayController (very similar to the one used
> in mmalc's Bookmarks example) which I want to set as data source of a
> table view to allow drag and drop. When I do this in IB it works fine
> but as I need access to the same array controller from different views
> which are not in the same nib, I have to instantiate the array
> controller programmatically:
>
> GFFClipListArrayController *ac = [[GFFClipListArrayController alloc] init];
> [ac setObjectClass:[GFFClip class]];
>
> I bind the controller to a class implementing the standard KVB methods
> for to-many relationships:
>
> [arrayController bind:@"contentArray" toObject:self
> withKeyPath:@"clipsArray" options:nil];
>
> Before I bind the table's content and selectionIndexes (and the table
> columns) to the array controller, I try to set the array controller as
> the table's data source:
>
> [tableView setDataSource:self]; // Where self is an instance of my
> array controller subclass
>
> The above unfortunately results in the following error:
>
> *** Illegal NSTableView data source (<GFFClipListArrayController:
> 0x5a97ea0>[object class: NSMutableDictionary, number of selected
> objects: 1]). Must implement numberOfRowsInTableView: and
> tableView:objectValueForTableColumn:row:
>
> Now, I know that I don't need to implement the afore mentioned
> methods, as I didn't need them when I set the array controller as data
> source in the nib and neither are they implemented in mmalc's example.
> But it's clear that I'm missing something.
>
> Any ideas as to what that something might be?
>
> chris
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden