• 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: printPanelDidEnd:returnCode:contextInfo: variable isn't updated
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: printPanelDidEnd:returnCode:contextInfo: variable isn't updated


  • Subject: Re: printPanelDidEnd:returnCode:contextInfo: variable isn't updated
  • From: Kevin Walzer <email@hidden>
  • Date: Tue, 10 Aug 2010 23:08:30 -0400
  • Organization: WordTech Communications LLC

On 8/10/10 4:28 PM, Quincey Morris wrote:

Based on the NSLog statements, I can tell that printResult is being correctly updated, but for some reason that value never makes it to the other function. I understand the selector method doesn't return a value; that's why I'm assigning the value to the printResult variable.  I don't believe it should be an error of variable scope, as the variable printResult is defined at the global level of the code, outside any functions or class definitions.

Any thoughts about what I'm doing wrong here?

Yup. The issue is not whether the didEnd method returns a value. The issue is the beginSheet pattern is asynchronous. When beginSheet... returns, the didEnd method has *not* been invoked yet -- the sheet probably isn't even visible yet. That all happens later, and at the end of all of it, your didEnd method is invoked so that you can do whatever should happen when the sheet is dismissed.

There isn't any way to make the beginSheet... pattern synchronous. (Well, you might be able to do it by running the run loop locally, but I wouldn't suggest considering that approach.) Instead, if you want synchronous behavior, use runModal instead. That will use a panel (separate window) instead of a sheet, but that tradeoff is common the to the beginSheet/runModel pattern used throughout Cocoa.

I've decided to address this by refactoring the delegate code to call a function that decides how to handle printing based on the returnCode of the delegate. It seems to hiccup the first time the command is called because it passes NSOKButton (and thus printing the document) regardless of what's clicked; but later print sessions are correctly handled. This is still a bug, but I think it's one I can live with because most users likely won't notice it.


--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
_______________________________________________

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: 
 >printPanelDidEnd:returnCode:contextInfo: variable isn't updated (From: Kevin Walzer <email@hidden>)
 >Re: printPanelDidEnd:returnCode:contextInfo: variable isn't updated (From: Quincey Morris <email@hidden>)

  • Prev by Date: -[NSBrowser setReusesColumns:] broken?
  • Next by Date: Re: How to search for specific bindings in IB
  • Previous by thread: Re: printPanelDidEnd:returnCode:contextInfo: variable isn't updated
  • Next by thread: Handling NSManagedObjectContextDidSaveNotification from different threads
  • Index(es):
    • Date
    • Thread