On Tue, 27 Jan 2009 17:10:20 -0800, Jerry Krinock <je...@ieee.org> said: >Butt if the possible problem involves a document, I believe it would >be a better user experience to use a sheet instead of a dialog. But, >arghhh, the method > -[NSApp >beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:] >returns immediately, sending its return message to a modal delegate >selector. So I must go back up the nest, all the way up to the event >which drove the process, and split all these methods into two methods, >the code "before" and "after" the sheet runs. Repeat this for all >other possible entry points into this innermost method. And there >goes another afternoon. > >-(void)methodC1 { > // Some code here (C1) > > [NSApp beginSheet:... > modalForWindow:... > modalDelegate:self > didEndSelector:@selector(didEndSheet:returnCode:contextInfo:) >}
The delegate does not have to be self, and the didEndSelector does not have to be named didEndSheet: (it can have any name you like, as long as its parameters are NSWindow*, int, void*). So, yes, it's true that methodC1 now ends and we have to re-enter elsewhere, but it is up to you *where* we reenter, and you can use that fact to help straighten out some of the logic. Furthermore, when there is a sequence of events that can bring up a sequence of sheets in various ways according to various logic, don't forget about contextInfo. The contextInfo that you hand in to the call to beginSheet: comes back out in your didEnd method, so it can tell that method where to go next. It might be some sort of carrier of state and/or even an invocation. m. -- matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/> A fool + a tool + an autorelease pool = cool! One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf> AppleScript: the Definitive Guide - Second Edition! <http://www.amazon.com/gp/product/0596102119> _______________________________________________ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com