Sorry - I forgot to copy to the list.

Jeremy

--

> Begin forwarded message:
> 
> From: Jeremy Hughes <moon.rab...@virginmedia.com>
> Subject: Re: didPrint selector not called
> Date: 16 December 2016 at 19:15:10 GMT
> To: John McCall <rjmcc...@apple.com>
> 
>> On 16 Dec 2016, at 17:24, John McCall <rjmcc...@apple.com> wrote:
>> 
>>> On Dec 16, 2016, at 8:45 AM, Jeremy Hughes <moon.rab...@virginmedia.com> 
>>> wrote:
>>> Hi,
>>> 
>>> I’m overriding printDocumentWithSettings in order to get a notification for 
>>> when printing has finished, but the didPrint selector is never called.
>>> 
>>> This is the code:
>>> 
>>> class func document(document: NSDocument, didPrint: Bool, contextInfo: 
>>> UnsafeMutablePointer<Void>)
>>> {
>>>     print("document was printed”)
>>> }
>>> 
>>> 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)
>>> }
>>> 
>>> Does anyone know why this doesn’t work?
>> 
>> The selector is invoked on the delegate object that you pass.  Since the 
>> selector is for a class method on Document, the delegate needs to be the 
>> class object for Document, which I assume it probably isn't.
>> 
>> It does seem kindof weird to be ignoring the delegate/selector pair that was 
>> passed in, though.
>> 
>> John.
> 
> Thanks!
> 
> I’ve changed the method to an instance method and passed in self as the 
> delegate - it works fine now.
> 
> Jeremy
> 


_______________________________________________

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