• 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: numberOfRowsInTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: numberOfRowsInTableView


  • Subject: Re: numberOfRowsInTableView
  • From: Bill Bumgarner <email@hidden>
  • Date: Fri, 25 Apr 2003 19:30:30 -0400

On Friday, Apr 25, 2003, at 08:59 US/Eastern, email@hidden wrote:
How do I know in my numberOfRowsInTableView which NSTableView (if I have
more then one) was sending a message? Any example code is apreciated.

First, the delegate method is declared as follows:

// Obj-C
- (int)numberOfRowsInTableView:(NSTableView *) aTableView;

// Java
public int numberOfRowsInTableView(NSTableView aTableView);

// Python via PyObjC
class MyTableDataSource(..., NSTableDataSource):
def numberOfRowsInTableView_(self, aTableView):

In all cases, the aTableView argument is the table requesting the # of rows for that table. Assuming you have an IBOutlet -- an instance variable -- that is connected to the table view, you can simply compare the references directly:

- (int)numberOfRowsInTableView:(NSTableView *) aTableView
{
if (aTableView == raceCarTableView)
return [raceCars count];
}

Or, if you are feeling pedantic, you could do it the OO way:

- (int)numberOfRowsInTableView:(NSTableView *) aTableView
{
if ([aTableView equals: raceCarTableView])
return [raceCars count];
}

In general, you'll find the answer to many such questions in the Tasks & Concepts guide included with the developer documentation. See:

file:///Developer/Documentation/Cocoa/TasksAndConcepts/ ProgrammingTopics/

b.bum
_______________________________________________
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.

  • Prev by Date: Re: formatter use for whitespace
  • Next by Date: OS9 Icons in OSX apps
  • Previous by thread: Re: numberOfRowsInTableView
  • Next by thread: Problems Tabbing through NSTableViews with non-Text controls
  • Index(es):
    • Date
    • Thread