On Dec 16, 2016, at 08:45 , Jeremy Hughes <moon.rab...@virginmedia.com> 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to