elegant sheet cascade handling?
elegant sheet cascade handling?
- Subject: elegant sheet cascade handling?
- From: Matt Neuburg <email@hidden>
- Date: Tue, 10 Apr 2007 09:19:51 -0700
- Thread-topic: elegant sheet cascade handling?
Has anyone come up with an elegant, maintainable, legible way to express a
logical process that is periodically interspersed with sheets shown to the
user?
Right now, I've got a logical process that is periodically interspersed with
*modal alerts*, so it's all in one method. I'd like to change these modal
alerts to sheets, but of course this means it can't so simply be all in one
method, because as soon as you show a sheet you have to fall out of the
current method. (That is why I started by developing the app usign modal
alerts.)
I don't really want to explode my logic, which is currently very neatly
expressed in a single method, by spreading it over a dozen different methods
with a complicated, illegible, unmaintainable, implicit relationship to one
another, that I'd be scared to modify as I continue to modify my app's
behavior. I guess what I'd really like to do is keep reentering the very
same method and somehow use an expression of state to skip past the part of
the process we've already passed through. However, I'm open to other
suggestions.
(Yes, I could make these sheets application-modal, but I have religious
objections to doing that.)
Just to clarify, here is a schema (with all the details left out) of the
start of my method as it stands right now (it is actually much longer):
- (void) checkStatus: (NSString*) path {
// ... lots of stuff ...
if (!doc) {
[NSApp presentError:err];
} else {
// so far, so valid
// ... stuff ...
if (!entry || ![entry count]) {
NSAlert* alert = [NSAlert alertWithMessageText:...];
int button = [alert runModal];
if (button == NSAlertDefaultReturn) {
// ... stuff ...
}
return;
}
... stuff ...
if (item && [item count]] && ...) {
NSAlert* alert = [NSAlert alertWithMessageText:...];
int button = [alert runModal];
if (button == NSAlertDefaultReturn || button == NSAlertOtherReturn) {
// ... stuff ...
}
return;
}
// ... stuff ...
if (item && [item count] && ...) {
NSAlert* alert = [NSAlert alertWithMessageText...];
[alert runModal];
return;
}
// ... lots more ...
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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