tags:

views:

18

answers:

1

In my application I open a sheet window for user input. Because the window is complex and has a few textfields and a few buttons I created a separate controller for it (InputWindowController).

When the sheet is closed I want to receive some values from the InputWindowController but I don't know how. In all samples I found the controls in the sheet are connected to Outlets in the main controller but that is not what I want. If I do like that I don't need a separate controller.

Also I am not exactly sure what the ContextInfo is for. You can set it right before the sheet should open and you can receive it when it is closed. If I could change the contextInfo in the sheet while it is open it really would help a lot.

+1  A: 

When the sheet is closed I want to receive some values from the InputWindowController but I don't know how.

Give the InputWindowController a property for a delegate, and a protocol specifying the method that that delegate must implement. Have that method be the way that the InputWindowController communicates the end of the sheet back to the object that wanted to run the sheet.

I would suggest making a model object that holds whatever values are displayed and editable in the sheet. Give the InputWindowController a property by which to hold one such model object. Then, when the object that wanted to run the sheet receives the InputWindowController's notification that the sheet has ended, the object that wanted to run the sheet asks the InputWindowController for the model object.

Alternatively, the object that wants to run the sheet can set up key-value observing on the model object before invoking the InputWindowController. That way, it will receive (and be able to save and make undoable) those changes to the model object's properties as they happen; then, there is nothing further to do at the end of the sheet.

Peter Hosey
I did the model object and the delegate and it works fine. Thanks
Holli