• 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: same table, different delegates
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: same table, different delegates


  • Subject: Re: same table, different delegates
  • From: Koen van der Drift <email@hidden>
  • Date: Thu, 25 Dec 2003 15:52:49 -0500

On Dec 25, 2003, at 3:36 PM, Jonathan Jackel wrote:

I have a window with a table to display some data. The window is the delegate so I set up all the code for populating, sorting the table in the window code.

Do you mean delegate or datasource? Or both? It is relatively common to have a separate object, called a controller, handle this chore. Typically you would not make a user interface element (a window or a view) the delegate or datasource of a tableview.


The windowcontroller I have for the first window is both the delegate and datasource for the table the first window is displaying. So it has methods such as -(int)numberOfRowsInTableView:(NSTableView *)aTableView and the like, but also -(void)tableView:(NSTableView *)aTableView didClickTableColumn:(NSTableColumn *)aTableColumn for sorting purposes.

For the second window, the data is completely different, but needs to be displayed in the same way, with the same columns and sorting code.

Now I am adding a feature to the app that uses different window, but the same table, using different data.

Do you mean it uses the same class of table? Or the same instance?


I mean the same class, so the actual data it is displaying is different for both windows (the windows and their controllers are different classes).

I understand the MVC concept and already use it in my app, but the data (model) differs for each window, so I assumed I cannot use it in this case.

So my thought was to make a separate MyTableView class, and let the class take care of displaying, and remove -(int)numberOfRowsInTableView:(NSTableView *)aTableView etc from the windowcontroller. The controller then just has to make sure that the table gets the data, and MyTableView takes care of the rest. Does NSTableView have methods I can use instead of -(int)numberOfRowsInTableView:(NSTableView *)aTableView etc?


thanks,

- Koen.
_______________________________________________
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.

References: 
 >same table, different delegates (From: Koen van der Drift <email@hidden>)
 >Re: same table, different delegates (From: Jonathan Jackel <email@hidden>)

  • Prev by Date: Re: Table Data and NSArrayController
  • Next by Date: Page margins and NSPrintInfo
  • Previous by thread: Re: same table, different delegates
  • Next by thread: Re: same table, different delegates
  • Index(es):
    • Date
    • Thread