Objective C Tutorial - Objective C continue Statement






continue statement causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.

Example

#import <Foundation/Foundation.h>
 
int main ()
{
   /* local variable definition */
   int a = 10;

   /* do loop execution */
   do
   {
      if( a == 15)
      {
         /* skip the iteration */
         a = a + 1;
         continue;
      }
      NSLog(@"value of a: %d\n", a);
      a++;
     
   }while( a < 20 );
 
   return 0;
}




Skipping for

#import <Foundation/Foundation.h>
 
int main ()
{
  int i;
    for (i = 0; i < 5; i++)
    {
        if ((i % 2) != 0)
        {
            continue;
        }
        NSLog (@"The value of i = %i", i);
    }  
 
   return 0;
}

The code above generates the following result.