• 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: Modal Sheet without Spaghetti?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Modal Sheet without Spaghetti?


  • Subject: Re: Modal Sheet without Spaghetti?
  • From: Jan Brittenson <email@hidden>
  • Date: Wed, 28 Jan 2009 14:19:08 -0800

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


  • Follow-Ups:
    • Re: Modal Sheet without Spaghetti?
      • From: Alex Kac <email@hidden>
References: 
 >Modal Sheet without Spaghetti? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Check URL Status
  • Next by Date: Re: Modal Sheet without Spaghetti?
  • Previous by thread: Re: Modal Sheet without Spaghetti?
  • Next by thread: Re: Modal Sheet without Spaghetti?
  • Index(es):
    • Date
    • Thread