Use NSTimer In iPhone

We create a small project using NSTimers.Its simple to use in a application. For the random movement of square, we are used timer.

Step 1: Create a new project in Xcode using View-base application.

Step 2: In your viewcontroller class, need to add the following code:



 Step 3: Now compile and run your Simulator.(See Figure 1)

Figure 1: Random movement of Square.

You can downloaded SourceCode from here TimerExample 2

Leave a Comment: