• 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: Have sheet delay until done?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Have sheet delay until done?


  • Subject: Re: Have sheet delay until done?
  • From: Carl Harris <email@hidden>
  • Date: Wed, 02 Sep 2009 05:51:53 -0400

Chase Meadors wrote:
The problem is, the -runNewItemSheet method is
returning right after starting the sheet. What I want is for it to
wait until the didEnd selector is called to return from the -
runNewItemSheet method. That way, "readyNewItem" will be properly
assigned and not nil.

Is there any way I can accomplish this while still allowing the panel
to work (IBActions etc.) but not return from the original calling
method? I'm drawing a blank here.

This can be accomplished, by running the panel as an application-modal dialog.


http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Sheets/Tasks/UsingAppModalDialogs.html

Using a modal dialog means that the user can't do anything else with your application until the dialog is dismissed, so you want to avoid this approach, particularly in a application with multiple independent windows.

Often, when I find myself wanting to do this sort of thing, it's because I'm thinking about what the code needs to do sequentially. Take a step back and think of the UI as providing events that allow your objects to attain some state, and then decide what actions need to occur when that state is attained. Take the part that happens in "someMethod" when the "readyNewItem" property changes state, and arrange to have that code invoked when the didEndSelector: is invoked. This will avoid the need for a modal dialog (and its associated negatives) and will make your code more consistent with the intended use of the sheet API in Cocoa.


_______________________________________________

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


  • Prev by Date: NSOutlineView Source List not looking like expected
  • Next by Date: After changing to MacOS 10.6 XCode no longer compiles
  • Previous by thread: Re: Have sheet delay until done?
  • Next by thread: Can't perform selectors after delay in a secondary thread?
  • Index(es):
    • Date
    • Thread