Re: Passing TableView information into a new dialog
Re: Passing TableView information into a new dialog
- Subject: Re: Passing TableView information into a new dialog
- From: Quincey Morris <email@hidden>
- Date: Tue, 18 Nov 2008 23:41:37 -0800
On Nov 18, 2008, at 13:22, Luis wrote:
My objective is to when a user right-clicks on a row in a TableView
and selects from the context menu an option, to show a new dialog
that handles that option.
How would I go to let the new dialog to know the information that
was present in the row that was selected?
The main dialog with the table view and the new dialog have diferent
controllers and thus diferent class files...
Well, it depends. Here's one way ...
Presumably, there's an array that contains the information that the
table view displays -- that's your data model.
Presumably, the "new" dialog just wants to update one element of the
data model array, and doesn't really need to know anything about the
table view itself.
Presumably, the "main" and "new" dialog controllers are subclasses of
NSWindowController.
So, add an action method in the "main" controller that's used by the
context menu item. Also add an IBOutlet to the controller for the
table view, and hook it up in IB. In the action method, retrieve the
"clickedRow" from the table view via the outlet. That's the index of
the data model element that you're interested in.
Pass that data model element as a parameter when you create the "new"
dialog controller. Make sure that any changes you make to the data
model as a result of the new dialog are done KVO-compliantly -- so
that these changes will show up in your table automatically.
That's the general idea, though the details might vary depending on
what exactly you're trying to do.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden