Use NSTimer in Iphone

NS TIMER

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 Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">