nstimer Questions

21

Solved

How can I make a countdown with an NSTimer using Swift?
Gulden asked 31/3, 2015 at 17:15

6

Solved

I am new to iOS programming. I am working on words matching game. In this game I need to implement time counter which shows minutes and seconds. I want when my game is started my timer to start wit...
Porkpie asked 19/5, 2012 at 7:17

17

Solved

I tried var timer = NSTimer() timer(timeInterval: 0.01, target: self, selector: update, userInfo: nil, repeats: false) But, I got an error saying '(timeInterval: $T1, target: ViewController, se...
Contradistinction asked 3/6, 2014 at 5:9

3

Solved

I am trying to calculate the time it takes a vehicle to go between two checkpoints. I have setup the following timer to achieve this. func startTimer() { if hasStarted == true && timerSta...
Lance asked 12/6, 2018 at 22:12

2

Solved

I have a timer that runs to restart an alarm once it goes off. alarm = NSTimer.scheduledTimerWithTimeInterval( 60 * minutesConstant + secondsConstant, target:self, selector: Selector("endSessi...
Peddling asked 17/1, 2015 at 8:1

2

I'm trying to use NTTimer but it doesn't work. It is started here: timer = NSTimer.scheduledTimerWithTimeInterval(0.003, target: self, selector: "openFrameAnimation", userInfo: nil, repeats: true...
Lange asked 27/2, 2016 at 22:44

7

Solved

I have referred to countless other questions about a press-and-hold button but there aren't many related to Swift. I have one function connected to a button using the touchUpInside event: @IBActio...
Schnurr asked 12/12, 2015 at 3:28

4

Solved

I'm creating a countdown timer that counts down to an NSDate set in a UIDatePicker. I have a label that shows the date we're counting down to and that works fine. What I'm also trying to add is la...
Alarm asked 13/10, 2015 at 22:24

9

Solved

I'm developing an Android 2.3.3 application and I need to run a method every X seconds. In iOS, I have NSTimer, but in Android I don't know what to use. Someone have recommend me Handler; another...
Imminence asked 11/7, 2012 at 13:45

24

Solved

I'm trying to create an NSTimer in Swift but I'm having some trouble. NSTimer(timeInterval: 1, target: self, selector: test(), userInfo: nil, repeats: true) test() is a function in the same clas...
Pompei asked 3/6, 2014 at 5:21

6

Solved

I have two NSTimers in my iPhone app. DecreaseTimer works fine, but TimerCountSeconds crashes when I call [timerCountSeconds isValid] or [timerCountSeconds invalidate]. They are used like this: -(...
Caligula asked 11/9, 2010 at 19:32

10

Solved

I'm using an NSTimer like this: timer = [NSTimer scheduledTimerWithTimeInterval:30.0f target:self selector:@selector(tick) userInfo:nil repeats:YES]; Of course, NSTimer retains the target which ...
Croaker asked 29/5, 2013 at 18:54

8

Solved

While a UIScrollView (or a derived class thereof) is scrolling, it seems like all the NSTimers that are running get paused until the scroll is finished. Is there a way to get around this? Threads?...
Swine asked 3/3, 2009 at 3:40

13

Solved

Is it possible to determine whether my UIView is visible to the user or not? My View is added as a subview several times into a UITabBarController. Each instance of this view has an NSTimer that up...
Sam asked 8/10, 2009 at 10:24

5

Solved

I have this problem for a few days now and I don't get what I am doing wrong. My application is basically just creating some timers. I need to stop them and create new ones. But at the moment sto...
Whiteley asked 29/12, 2015 at 9:4

3

Solved

I add timer like this tim=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(repeatTim) userInfo:nil repeats:YES]; [[NSRunLoop mainRunLoop] addTimer:tim forMode:NSDefaultRun...
Haimes asked 11/9, 2013 at 15:21

10

Solved

I have a view controller that uses an NSTimer to execute some code. What's the best way to detect when the app is going to the background so I can pause the timer?
Melodic asked 25/1, 2012 at 23:16

4

I want to stop this timer and then restart it from where I stopped it. secondsTimer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(addSeconds), userInfo: nil, repeats:...
Willard asked 17/10, 2017 at 14:31

11

Solved

How do people deal with a scheduled NSTimer when an app is in the background? Let's say I update something in my app every hour. updateTimer = [NSTimer scheduledTimerWithTimeInterval:60.0*60.0 ...
Langbehn asked 7/12, 2011 at 13:13

8

Solved

I am creating and firing a NSTimer with: ncTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(handleTimer:) userInfo:nil repeats:YES]; [ncTimer fire]; AND - ...
Galsworthy asked 23/1, 2011 at 11:31

5

Solved

I need to call a method when my app starts and then call the same method every 5 seconds. My code is pretty simple: // Call the method right away [self updatestuff:nil] // Set up a timer so the...
Inarticulate asked 26/5, 2012 at 6:36

9

Solved

I want to be able to schedule three small events in the future without having to write a function for each. How can I do this using NSTimer? I understand blocks facilitate anonymous functions but c...
Klink asked 17/2, 2013 at 19:7

10

Solved

Does any one know when is the best time to stop an NSTimer that is held reference inside of a UIViewController to avoid retain cycle between the timer and the controller? Here is the question in m...

1

Solved

Normally, I would use an optional variable to hold my Timer reference, as it's nice to be able to invalidate and set it to nil before recreating. I'm trying to use SwiftUI and want to make sure I'm...
Poetess asked 1/7, 2020 at 14:21

4

Solved

I need a long running task to be done in background as well as in foreground. This updates the core data. So to maintain UI responsive I created an another thread where I use different managedObjec...
Crossruff asked 14/3, 2013 at 9:26

© 2022 - 2025 — McMap. All rights reserved.