Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How to implement 2 datasources for 2 NSTableView

How to implement 2 datasources for 2 NSTableView
Thread Tools
Fresh-Faced Recruit
Join Date: Dec 2002
Status: Offline
Reply With Quote
Aug 4, 2003, 10:58 PM
 
Most of the examples that I have been studying involves one NSTableView in a window.

My question is how to implement two NSTableViews in a single window?

It would appear to me that it would only require to implement one version of the datasource methods and the implementation would be in the code of the datasource methods such as

-(int)numberOfRowsInTableView: (NSTableView *)aTableView;

and in the code of the datasource method, it needs to determine which tableView is making the call and then return with the appropriate number of rows based on the object/array that is viewed in the NSTableView.

If this is the case, then how do you determine which NSTableView made the call for the datasource method?
     
Fresh-Faced Recruit
Join Date: Dec 2001
Location: Wisconsin
Status: Offline
Reply With Quote
Aug 4, 2003, 11:08 PM
 
Compare aTableView to your instance variables of the two tableviews. Say your instance variables are tableView1 & tableView2.
if (aTableView == tableView1) {
return someNumber;
} else if (aTableView == tableView2) {
return someOtherNumber;
}
     
Fresh-Faced Recruit
Join Date: Dec 2002
Status: Offline
Reply With Quote
Aug 5, 2003, 07:28 PM
 
Originally posted by seppak:
Compare aTableView to your instance variables of the two tableviews. Say your instance variables are tableView1 & tableView2.
In the datasource methods, the argument aTableView allows the method to determine which of the NSTableView made the call.

My question is how is this handled with delegate methods such as
- (void)tableViewSelectionDidChange:
(NSNotification *)n

where there is no tableView argument to check which of the NSTableView of the window made the call for the delegate?

Thanks.
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Aug 5, 2003, 08:22 PM
 
Originally posted by macaroni:
where there is no tableView argument to check which of the NSTableView of the window made the call for the delegate?
RTFM NSNotification, paying particular attention to the userInfo and object methods.
     
Dedicated MacNNer
Join Date: Jul 1999
Status: Offline
Reply With Quote
Aug 6, 2003, 12:51 PM
 
like so maybe:


Code:
- (int)numberOfRowsInTableView: (NSTableView *)aTableView { int rowCount; switch ([aTableView tag]) { case 100: rowCount = [queryArray count]; break; case 200: rowCount = [currentMediaArray count]; break; } return rowCount; } - (void)tableViewSelectionDidChange: (NSNotification *)aNotification { switch ([[aNotification object] tag]) { case 100: [self doThis] break; case 200: [self doThat]; break; } }
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:16 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2