Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 803349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:44:46+00:00 2026-05-14T23:44:46+00:00

For example, I have a huge switch control structure with a few hundred checks.

  • 0

For example, I have a huge switch control structure with a few hundred checks. They’re an animation sequence, which is numbered from 0 to n.

Someone said I can’t use variables with switch. What I need is something like:

NSInteger step = 0;
NSInteger i = 0;
switch (step) {
case i++:
    // do stuff
    break;

case i++:
    // do stuff
    break;

case i++:
    // do stuff
    break;

case i++:
    // do stuff
    break;

}

The point of this is, that the animation system calls a method with this big switch structure, giving it a step number. I want to be able to simply cut-copy-paste large blocks and put them in a different position inside the switch. for example, the first 50 blocks to the end.

I could do that easily with a huge if-else structure, but it would look ugly and something tells me switch is much faster.

How to?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:44:47+00:00Added an answer on May 14, 2026 at 11:44 pm

    By not doing it this way. A case label has to be a constant.

    Here’s one way to do this that might be better:

    Define a selector for each thing you want to do e.g.

    -(void) doOneThing;
    -(void) doAnotherThing;
    // etc
    

    Put them in an array:

    SEL anArray[] = { @selector(doOneThing), @selector(doAnotherThing) /* other selectors */, NULL };
    

    And then you can just iterate through them.

    SEL* selPtr = anArray;
    while (selPtr != NULL)
    {
        [self performSelector: *selPtr];
        selPtr++;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a huge directory list of URLs from my Web site. Example: /folder/folder2/folder3/page.htm
Here's the problem. I ,for example,have a string 2500.Its converted from byte array into
Example: I have an class that inherits from UIImageView. An object creates an instance
Example: I have a selector like this, which I give to another method as
I have a huge repository of files that are ordered by numbered folders. In
I have a huge table containing 161 million rows. The table structure is entryid(varchar),
Say we have huge static libraries with lots of unneeded features (in the example
I have a huge list of URL's, in the format: http://www.example.com/dest/uk/bath/ http://www.example.com/dest/aus/sydney/ http://www.example.com/dest/aus/ http://www.example.com/dest/uk/
I have a huge dictionary something like this: d[id1][id2] = value example: books[auth1][humor] =
Suppose a huge database. For example I have more than 4294967295(for mysql INT) users.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.