I am a newbie IOS developer, but I have a good amount of experience in Android development. My question is regarding the creating and use of interval specific timers.
In android I could easily make a timer like this:
timedTimer = new Timer();
timedTimer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
TimedMethod();
}
}, 0, 1000);
Where the interval is 1000 MS and the method TimedMethod() is called on every tick. How would I go about implementing a similar function in IOS?
Thanks so much for reading! Any help at all would be great! :-)
Thousands of iOS apps are built and published each day through Appy Pie's iOS app builder platform! Create your own native iOS mobile apps within a few minutes. Appy Pie's iPhone app builder gives you the perfect tools to create an app for the iOS with zero coding.
You can learn how to develop apps for Apple platforms for free without enrolling. With just an Apple ID, you can access Xcode, software downloads, documentation, sample code, forums, and Feedback Assistant, as well as test your apps on devices.
You can use a repeating NSTimer
like so:
- (void) startTimer {
[NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(tick:)
userInfo:nil
repeats:YES];
}
- (void) tick:(NSTimer *) timer {
//do something here..
}
Use
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerCallback) userInfo:nil repeats:YES];
In the same class as you called the above method, create a method called timerCallback
. This will be called every time your timer fires; every 1000 milliseconds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With