Proper parameters for closeAllDocumentsWithDelegate

前端 未结 1 763
野的像风
野的像风 2021-01-29 05:31

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

相关标签:
1条回答
  • 2021-01-29 05:44

    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.

    0 讨论(0)
提交回复
热议问题