Re: didPrint selector not called
Re: didPrint selector not called
- Subject: Re: didPrint selector not called
- From: Jeremy Hughes <email@hidden>
- Date: Fri, 16 Dec 2016 19:24:53 +0000
Thanks for the link.
I’ve looked at it, and I don’t think it applies in this case, because I’m not actually overriding the document(_:didPrint:contextInfo:) method, just providing it as a callback. There isn’t an override keyword before the method, and there isn’t a superclass method that I can call through to. I suppose it would apply if I had a subclass (of my document class) that needed to override the callback. Does that seem right to you?
Jeremy
--
> On 16 Dec 2016, at 18:26, Quincey Morris <email@hidden> wrote:
>
> 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/
>
> (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