I have a working (Cocoa) application but I'm not happy with it from a structural point of view, so I'd like some input as to the 'accepted' way of doing things.
The main points of the application are:
- It is document-based
- A bunch of parameters are set in a document.
- There is a 'run' button that displays a modal sheet that gathers a final ID parameter
- The application then goes and does stuff with the document parameters and the ID.
To make this work, I created a SheetController that controls a separate NIB file that gets the ID parameter.
The flow of is:
1. 'Run' button is calls the action run1 in MyDocument.
2. run1 calls the SheetController and makes it display the sheet.
3. SheetController has a variable that stores the sender that started it as a NSPersistentDocument (I couldn't make a MyDocument variable).
4. If NSOkButton is returned on sheetDidEnd, SheetController sends a message back to the sender that it stored (which is MyDocument), and calls the run2 method.
5. run2 then goes and processes everything.
This seems like a very silly way to achieve something that I could do in a few lines with Java. I could probably control the sheet from within MyDocument but it's probably ideal if it's separate.
How should I structure this?
For the record, all I want to achieve is the cocoa equivalent of:
The main points of the application are:
- It is document-based
- A bunch of parameters are set in a document.
- There is a 'run' button that displays a modal sheet that gathers a final ID parameter
- The application then goes and does stuff with the document parameters and the ID.
To make this work, I created a SheetController that controls a separate NIB file that gets the ID parameter.
The flow of is:
1. 'Run' button is calls the action run1 in MyDocument.
2. run1 calls the SheetController and makes it display the sheet.
3. SheetController has a variable that stores the sender that started it as a NSPersistentDocument (I couldn't make a MyDocument variable).
4. If NSOkButton is returned on sheetDidEnd, SheetController sends a message back to the sender that it stored (which is MyDocument), and calls the run2 method.
5. run2 then goes and processes everything.
This seems like a very silly way to achieve something that I could do in a few lines with Java. I could probably control the sheet from within MyDocument but it's probably ideal if it's separate.
How should I structure this?
For the record, all I want to achieve is the cocoa equivalent of:
Code:
String subjectID = JOptionPane.showInputDialog(null, "Enter subject identifier",
"Subject", JOptionPane.QUESTION_MESSAGE);
if (subjectID != null) {
// process...
}