• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: didPrint selector not called
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: didPrint selector not called


  • Subject: Re: didPrint selector not called
  • From: Jeremy Hughes <email@hidden>
  • Date: Fri, 16 Dec 2016 21:10:50 +0000

> 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 (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


References: 
 >didPrint selector not called (From: Jeremy Hughes <email@hidden>)
 >Re: didPrint selector not called (From: Quincey Morris <email@hidden>)
 >Re: didPrint selector not called (From: Jeremy Hughes <email@hidden>)
 >Re: didPrint selector not called (From: John McCall <email@hidden>)
 >Re: didPrint selector not called (From: Jeremy Hughes <email@hidden>)
 >Re: didPrint selector not called (From: John McCall <email@hidden>)
 >Re: didPrint selector not called (From: Jeremy Hughes <email@hidden>)
 >Re: didPrint selector not called (From: Jeremy Hughes <email@hidden>)
 >Re: didPrint selector not called (From: Jeremy Hughes <email@hidden>)

  • Prev by Date: Re: didPrint selector not called
  • Next by Date: Re: didPrint selector not called
  • Previous by thread: Re: didPrint selector not called
  • Next by thread: Re: didPrint selector not called
  • Index(es):
    • Date
    • Thread