iPhone Do loop in Objective c


 

iPhone Do loop in Objective c

As you know, the concept of iphone do loop function is almost same in objective c programming. So, here in this tutorial of "Do loop in Objective c" i would explain only the necessary part with example.

As you know, the concept of iphone do loop function is almost same in objective c programming. So, here in this tutorial of "Do loop in Objective c" i would explain only the necessary part with example.

iPhone Do loop in Objective c

As you know, the concept of loop is almost same in objective c programming. So, here in this tutorial of "Do loop in Objective c" i would explain only the necessary part with example.

But first of all let's create a new project in Xcode "foundation tool", which is a basic project type for objective c programming. We are also using the same. 

Once you create the new project, go into source folder where you will find the .m file. This is the only file where you'll be writing your all code.

Code of Do loop in objective c

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {

    //Do Loop in Objective c, an example

int Val = 0;

    do{

        NSLog(@"Value is = %i", Val);

      Val++;

    }

    while(Val <= 11);

}

In this small do loop program, we have created a main function and within the main function we are creating a int type variable and assigning a value to it. Then we have started the do loop ( do {...} ) and given the condition in while loop.
The loop will learn until the condition get true. The output of the application will look like as in given image.

Download Code

Ads