> 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)
> }

If I cast the NSMutableDictionary to an NSDictionary, I can recast that to a 
Swift dictionary:

override func printDocument(sender: AnyObject?)
{
        let didPrintSelector = #selector(document(_:didPrint:contextInfo:))
        
        let printSettings = (printInfo.dictionary() as NSDictionary) as! 
[String : AnyObject]

        printDocumentWithSettings(printSettings, showPrintPanel: true, 
delegate: self, didPrintSelector: didPrintSelector, contextInfo: nil)
}

Is this a general thing? If I want to cast an NSMutableType to a Swift Type I 
have to cast it to an NSType first?

Maybe it's changed in Swift 3 (I’m still on 2.2) but I haven’t found any Apple 
documentation about this.

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