Search code examples
macosswiftappkitnsdocument

NSDocument callback method signature


I trying to use the runModalSavePanelForSaveOperation method on NSDocument in Swift, but I get an "unrecognized selector sent to instance" exception when the save panel closes. The method call looks like this:

self.runModalSavePanelForSaveOperation(.SaveOperation, delegate: self, didSaveSelector: Selector("document:didSave:contextInfo"), contextInfo: nil)

And this is what the callback looks like:

func document(document: NSDocument, didSave: Bool, contextInfo: UnsafeMutablePointer<Void>) {}

Based on this answer to a similar question it looks like the method signature should be correct. Am I missing something?


Solution

  • There is one colon missing in the selector. It should be

    Selector("document:didSave:contextInfo:")