• 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
Setting subclass of NSArrayController as data source programmatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Setting subclass of NSArrayController as data source programmatically


  • Subject: Setting subclass of NSArrayController as data source programmatically
  • From: Christian Schneider <email@hidden>
  • Date: Thu, 28 Apr 2005 16:03:27 +0200

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

  • Follow-Ups:
    • Re: Setting subclass of NSArrayController as data source programmatically
      • From: Christian Schneider <email@hidden>
  • Prev by Date: Re: Introduction
  • Next by Date: Printing and views
  • Previous by thread: Re: NSMenu delegate broken?
  • Next by thread: Re: Setting subclass of NSArrayController as data source programmatically
  • Index(es):
    • Date
    • Thread