Communicating with NSTableView delegate
Communicating with NSTableView delegate
- Subject: Communicating with NSTableView delegate
- From: aperantos lists <email@hidden>
- Date: Mon, 12 Apr 2004 14:16:46 +0100
Hi all,
I'm another of those new to Cocoa so I hope I'm not asking one of those
questions that is always being asked - I have read as much as I can
find on Google (web and groups) before admitting defeat.
As my first project I have decided to write a preference pane for
system preferences which doesn't do anything other than manipulate its
own defaults, I later plan on writing a background app to work with
these settings. I'm having a problem with a table view though.
SITUATION: I have a subclass of NSPreferencePane and an object I have
written to be a data source and delegate for an NSTableView. This
object is instantiated as follows:
IBOutlet NSTableView *myTable;
ViewTableDelegate *listDataSource;
listDataSource = [[ViewTableDelegate alloc] init];
[myTable setDataSource:listDataSource];
[myTable setDelegate:listDataSource];
Everything works fine, I have added methods to the object
(ViewTableDelegate) so that I can tell it to add or remove entries from
the table.
ISSUE: When a row is selected in the table view I want my main object
(not sure of the correct vernacular but it is the subclass of
NSPreferencePane) to check the table to see what is selected and load
the appropriate file. I believe I need to use the
tableViewSelectionDidChange delegate method, but how do I get this
method to communicate back to the main object? Is the only way to
register with a notification center, or is there a way to 'find' the
main object? I tried using NSBundle to find the primaryClass,
unfortunately it only found the class and not the instance. Can I pass
a selector to my data source object to 'register' itself for selection
events? I want to make my class as reusable as possible.
Or am I going about this all wrong, should I be doing something in IB
or be subclassing the NSTableView?
Any help, or even just pointers to information elsewhere would be
greatly appreciated.
Many thanks,
Michael
P.S. I'm using Project Builder as I'm on x 10.2.8
_______________________________________________
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.