I am writing an app that needs to have multiple documents in one window (as was asked about here. So I can\'t just make it a \"document-based application\", but I am still tryin
This method simply executes -canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo: for all open windows. So look at its documentation. (Linked above.)
The short form: You can pass a delegate object, which will be informed about the close request via the method that responds to the selector, you passed.
So let's say, the object that should be informed is the app delegate, then you pass this as delegate
parameter and write a method in the app delegate, whose selector you pass as selector
parameter. In Swift you must decorate that method (Swift: function) with @objc
.
The contextInfo
is any user-definable data to pass or not. It is simply passed through. It is a "communication channel" from caller in your code to the delegate method, i. e. signaling the reason for the close. You can pass nil
for it.
Even I did not test it, but typically you can pass nil
for delegate
, too. In such a case you should be able to pass NULL
(it is no type) for the selector. Just try it. Then you do not need an empty method.