草庐IT

canCloseDocumentWithDelegate

全部标签

objective-c - 如何实现 NSDocument 方法 -canCloseDocumentWithDelegate :shouldCloseSelector:contextInfo: in Swift?

在我的应用程序中,NSDocument子类关键任务硬件——用户真的不想意外关闭文档!所以,我实现了canCloseDocumentWithDelegate...以显示NSAlert并在关闭前询问。我现在正尝试在一个用Swift编写的应用程序中实现同样的事情。由于答案是异步的,“应该关闭”的结果被传递给委托(delegate)的回调,而不是简单地返回。在-canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo:的文档中,它说:TheshouldCloseSelectorcallbackmethodshouldhavethe