I want to write some code in a method in iOS and that method should be called for every 1 sec. Can anyone help me to do this. Thanks in Advance.
Asked
Active
Viewed 3,086 times
-2
-
1This is very common question. no need to ask here. U can found this easyly by searching google or SO old question. http://stackoverflow.com/questions/5674375/calling-a-method-after-each-60-seconds-in-iphone http://stackoverflow.com/questions/446717/how-can-i-create-a-count-down-timer-for-cocos2d – CRDave Apr 01 '13 at 07:42
1 Answers
3
[NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(thisIsCalledEvery1Second:)
userInfo:nil
repeats:YES];
Read Apple docs for NSTimer

msk
- 8,885
- 6
- 41
- 72
-
-
@vijay add where you want to fire action.viewdidload or button action – Krutarth Patel Nov 17 '16 at 09:03
-
Timer.scheduledTimer(withTimeInterval: , repeats: true, block: { (timer) in print("That took a second") }) – srivas Nov 21 '17 at 21:02