Search code examples
objective-cgoto

how to use goto statement in objective c?


I want to skip some line of code by checking if condition in the same method. I used goto statement but it showed "cannot jump from this goto statement to the label". Is there any other way I can skip code? what I do is..

if(condition)
       goto skipped;
 //code to skip
 //code to skip

skipped:
 //code to execute

Solution

  • There are surely legitimate uses for goto, so I think this deserves a proper answer:
    Some possible reasons why you might be failing:

    • Scope issues (Trying to jump to new functions, etc)
    • Jumping across declarations/destructors

    Read more : http://en.cppreference.com/w/cpp/language/goto