Make a countdown


#1

Hi, I don’t know where else to put this, so I’m just going to put it here, since this is what chapter I’m on.

When going through these books (I just read the Objective-C Programming: The Big Nerd Ranch Guide) i tend to take what I have just learned and take it as far as I can. So for instance, after making the random number generator app, I started creating another small app that would say something funny when you clicked on one of 8 buttons.

Now, what I am trying to do is have the user click on a button, and have that button display a timer in a text field next to it. So for instance, this button is named “Enemy Red:” and when you click on it, the textfield next to it starts a countdown from 8:00 (8 minutes) to 0 seconds. The only problem is that I have no idea how to do this, and even googling it hasn’t helped me. Can I get any help here? I apologize if this is covered later in the book by the way, but I searched through it and didn’t find anything that helped me.


#2

Obviously your specific example is not covered in the book but the coding you are searching for is best covered in Chapter 24 “NS Timer”. However, there are some other bits that you really need to master on the way to using and understanding the event loop principle. I would suggest that you shelve your project until you get back there.


#3

As loumaag points out you would want to use an NSTimer (Ch24), but to understand NSTimer you will need to understand target/action (Ch5). So I would suggest at least getting through Chapter 5 before you check out NSTimer. We think that you’ll learn the most by following the book in order and doing the exercises, but in this case the challenge you’ve set for yourself seems pretty doable with a little extra knowledge (NSTimer). Good luck!


#4

Alright! Thanks for the info! I’ll just have to shelve it for a little while until I get through Chapter 5, and then Chapter 24.