Spencer
Spencer

Reputation: 79

Objective-C beginner; what do I need to create a countdown timer?

I've just started learning Obj-C. As an alternative to the usual maths examples, I thought I'd try and create a countdown timer - perhaps one that could time multiple events.

Have looked at NSTimer but am having trouble working it out - especially which method to use.

I've tried to find some source code - but so far it's all Cocoa stuff which is even more difficult to work out.

If someone could point me in the right direction - that would be great.

If this is too ambitious for a newbie - please let me know and perhaps suggest a project that I can get stuck into.

Thanks for reading!

Upvotes: 1

Views: 11711

Answers (1)

Nicholas Riley
Nicholas Riley

Reputation: 44321

Before you start using timers, it's important to understand how run loops in Cocoa work. Try reading Apple's documentation on run loop management. There's an example of using NSTimer in there; hopefully by the time you get to it, you'll understand why things work the way they do.

For an even simpler example, check out this tutorial which creates a timer inside the main function.

The second Cocoa app I wrote was a simple timer. Of course, 8 years later I'm still maintaining it...

Upvotes: 3

Related Questions