> On 16 Dec 2016, at 20:17, Jeremy Hughes <moon.rab...@virginmedia.com> wrote: >>> I'm not an expert in this part of Cocoa. Are there implicit system >>> *callers* of this method, or is it more of a system *utility* that you're >>> expected to call from your own code? If it's the latter, then maybe >>> instead of overriding it you should just provide a different method that >>> calls it, doing whatever set up you need first and then passing in the >>> appropriate delegate and selector to do cleanup. >> >> It’s just an application method, which overrides the method that the system >> calls from printDocument when a user chooses Print.
Less confusingly: it’s a Document (subclass of NSDocument) method > I could override printDocument, but I’m not sure how to get the printSettings > that I need to pass through to printDocumentWithSettings. Looking at Apple's > documentation, I think I can get these by calling dictionary() on an > NSPrintInfo object. That returns an NSMutableDictionary, but the compiler > won’t let me use this as a printSettings argument: > > "Cannot convert value of type 'NSMutableDictionary' to expected argument type > '[String : AnyObject]’" > > Do I need to iterate through the NSMutableDictionary and create a Swift > Dictionary from it? > > Maybe I’ve missed an easier way of doing this. All I want to happen is to be > notified when the print operation is completed. This is what I’ve currently got. It works OK, but the dictionary conversion seems clunky to me. override func printDocument(sender: AnyObject?) { let didPrintSelector = #selector(document(_:didPrint:contextInfo:)) let dictionary = printInfo.dictionary() var printSettings = [String : AnyObject]() for key in printInfo.dictionary().allKeys { if let string = key as? String { printSettings[string] = dictionary.valueForKey(string) } } printDocumentWithSettings(printSettings, showPrintPanel: true, delegate: self, didPrintSelector: didPrintSelector, contextInfo: nil) } 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