Re: Have sheet delay until done?
Re: Have sheet delay until done?
- Subject: Re: Have sheet delay until done?
- From: Graham Cox <email@hidden>
- Date: Wed, 2 Sep 2009 12:59:28 +1000
On 02/09/2009, at 12:50 PM, Chase Meadors wrote:
the class keeps the "readyNewItem" property updated according to
what happens with the sheet. 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.
Thanks for any help.
You can't.
You need to refactor your code so that the code that needs to run when
the sheet is dismissed is triggered by the sheetDidEnd:... method. You
can't wait on a sheet completing then continue - the design is simply
not modelled around that approach. The only time that will work is if
you are running an application modal dialog, but a sheet is not
application modal.
I usually handle this by declaring an informal delegate protocol for
the controller class that handles the sheet, and setting the delegate
when I ask the controller to run the sheet. The controller implements
the sheetDidEnd: method, and if OK (or whatever) was clicked it
invokes the method on the delegate that I decided it would invoke.
Then the delegate (the original caller) performs the relevant task.
--Graham
_______________________________________________
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