Skip to content

NSTimer in Objective-C: Example (Video)

Learn how NSTimer works in Objective-C with a simple video tutorial: an app that increments an integer variable every second. Project download included.

In this video tutorial, we are going to show how a "Timer" works in Objective-C, using a simple app that increments an integer variable by one every second (or every "whatever you want").

Here is how NSTimer works "in broad strokes":

timer = [NSTimer scheduledTimerWithTimeInterval:1.0 // The timer fires every second
                    target:self     // This timer runs in this view
                    selector:@selector(contar)      // The contar method is run
                    userInfo:nil
                    repeats:YES];   // The timer is repeating, that is, it fires every second (in this case)

You can download the project for this video tutorial HERE.

“NSTimer in Objective-C: Example (Video)” by Ricardo Moya at jarroba.com, licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0. Registered at Safe Creative.

Ricardo Moya

I work in Machine Learning and Big Data. I like learning new technologies and explaining them as clearly as I can on this site.

You may also like

Comments

Leave a comment


This site uses Akismet to reduce spam. Learn how your comment data is processed.