• 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: Question about TableView - how do I know which tableView?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about TableView - how do I know which tableView?


  • Subject: Re: Question about TableView - how do I know which tableView?
  • From: Scott Anguish <email@hidden>
  • Date: Thu, 6 Feb 2003 00:37:35 -0500

I'm writing a little app that has two table views. I thought I needed two dataSource classes, but as Mike Beam points out in his "Working with tables" column, the methods that are required for tableView each expect to receive an NSTableView parameter "This argument allows for one dataSource object to manage data for multiple table views"


So presumably I can test aTableView in some way. I think I want to write something like
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
if [aTableView xxxxxx] isEqual: @"people"])
return [people count];
else
return [things count];
}


There are two different strategies for this.

The most common (and most flexible) is to ensure that there are variables in the class that are set to the NSTableView object. Declare them in the code, and then connect them up in InterfaceBuilder to the tables.

Then you'd simply do

if (aTableView == myNamesTableView)
do something
else


the other option, is to set a tag for each of the tableviews in Interface Builder. If you inspect the table view, you'll see a tag field. Set that to a unique number for each table, and then you could do

if ([aTableView tag] == 1) // its my names table
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Question about TableView - how do I know which tableView?
      • From: Denis Stanton <email@hidden>
References: 
 >Question about TableView - how do I know which tableView? (From: Denis Stanton <email@hidden>)

  • Prev by Date: Re: default Find Panel?
  • Next by Date: Delegation methods from NSOpenPanel?
  • Previous by thread: Re: Programmatically adding an NSTextField to an NSTextView
  • Next by thread: Re: Question about TableView - how do I know which tableView?
  • Index(es):
    • Date
    • Thread