I’m trying to make a pretty simple game and I’m stuck. Basically I want to make a UIImageView appear every 2 seconds. My problem is I can’t keep track of cumulative time. Right now I have this:
NSDate *date = [NSDate date];
NSTimeInterval secondsSinceNow = [date timeIntervalSinceNow];
NSLog(@"date = %@", date);
NSLog(@"secondsSinceNow = %f", secondsSinceNow);
It’s in my button function so its called when the user taps the button. It returns a decimal number always less than 1. I’ve tried it in the viewDidLoad method as well as it’s own method but neither work.
I think it would work if its in it’s own method that is check constantly, but I don’t know how to do that.
In short, I need a timer/counter that updates every second.
/*factory method was corrected here. should work without warnings by copying and pasting */
/*method was corrected because it needed parentheses around NSTimer */
taken from here
http://www.iphonedevsdk.com/forum/iphone-sdk-development/14403-nstimer-examples.html