Re: didPrint selector not called
Re: didPrint selector not called
- Subject: Re: didPrint selector not called
- From: Quincey Morris <email@hidden>
- Date: Fri, 16 Dec 2016 10:26:22 -0800
- Feedback-id: 167118m:167118agrif8a:167118sm8RTsDKr0:SMTPCORP
On Dec 16, 2016, at 08:45 , Jeremy Hughes <email@hidden> wrote:
>
> override func printDocumentWithSettings(printSettings: [String : AnyObject], showPrintPanel: Bool, delegate: AnyObject?, didPrintSelector: Selector, contextInfo: UnsafeMutablePointer<Void>)
> {
> let didPrint = #selector(Document.document(_:didPrint:contextInfo:))
>
> super.printDocumentWithSettings(printSettings, showPrintPanel: showPrintPanel, delegate: delegate, didPrintSelector: didPrint, contextInfo: contextInfo)
> }
Apart from the bug John described, where the selector is incorrectly for a class method…
It’s not absolutely clear, but I think this method comes under the aegis of “Advice for Overriders of Methods that Follow the delegate:didSomethingSelector:contextInfo: Pattern” in the OS X release notes archive:
developer.apple.com/library/content/releasenotes/AppKit/RN-AppKitOlderNotes/ <http://developer.apple.com/library/content/releasenotes/AppKit/RN-AppKitOlderNotes/>
(Do a text search within the page to find the heading.)
This’ll make your head hurt, but the essence of it is that you’re not allowed to throw away the selector that’s passed in to the method, and that’s exactly what you’re doing.
Instead, you need to arrange for your “didPrint” method to invoke the originally passed-in selector, and depending on the order in which things need to happen, you make have to construct an invocation. I think (but I’m not certain) that yours is the “easy” case where you don’t need to construct the invocation, but you’re going to have to figure that out.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden