I am doing one application.In that,i am calling one method for every 10 seconds using the timer.But after sometime that method is not calling. So,may i know the reason for why timer is stopped.
Asked
Active
Viewed 32 times
-2
-
share some code. – KKRocks Apr 25 '17 at 05:33
-
Just started the timer myTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(recordFile1:) userInfo:Nil repeats:YES]; – venkat Apr 25 '17 at 05:35
-
http://stackoverflow.com/a/25658491/2522457 -- plz check this. – Er.Shreyansh Shah Apr 25 '17 at 05:36
-
after somtimes means how much time ? – KKRocks Apr 25 '17 at 05:36
-
is your timer works on background ? – KKRocks Apr 25 '17 at 05:37
-
In foreground only. – venkat Apr 25 '17 at 06:00
2 Answers
1
If there is a ScrollView scrolling, the timer in NSDefaultRunLoopMode
will be stopped.
You can use this to fix it:
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];

mmackh
- 3,550
- 3
- 35
- 51

virgiltang
- 36
- 2
0
If you are checking Timer in Foreground and background, Timer will work continuously in foreground, But in background it will work only 10 mins, After that timer will not work.

Hari c
- 1,139
- 11
- 11