Re: Modal Sheet without Spaghetti?
Re: Modal Sheet without Spaghetti?
- Subject: Re: Modal Sheet without Spaghetti?
- From: Alex Kac <email@hidden>
- Date: Wed, 28 Jan 2009 16:45:37 -0600
That's how we do it. Of course, we try to handle all this in the
controllers, not in the model, so it propagates up to the controller
from the model via a delegate or something and then we use the state
machine there.
On Jan 28, 2009, at 4:19 PM, Jan Brittenson wrote:
Jerry Krinock wrote:
Does anyone have an idiom or way of appreciating this problem which
does not produce such spaghetti and headaches?
How about a state machine:
enum State { STATE_INIT, STATE_PREPARE, STATE_EXECUTE,
STATE_FINISHED, STATE_DEAD };
State state;
HandleEvent(event)
{
switch (state) {
case STATE_INIT:
// initialize here
state = STATE_PREPARE:
// fallthru
case STATE_PREPARE:
if (need_some_particular_state_first) { break; }
if (need_user_response) { ask_for_it(); break; }
state = STATE_EXECUTE;
// fallthru
case STATE_EXECUTE:
// do stuff
state = STATE_FINISHED; // so when display is dismissed we
continue
display_results();
break;
case STATE_FINISHED:
// wrap up
state = STATE_DEAD;
// fallthru
case STATE_DEAD:
break;
default:
assert(0);
}
}
_______________________________________________
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
Alex Kac - President and Founder
Web Information Solutions, Inc.
"I am not young enough to know everything."
--Oscar Wilde
_______________________________________________
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