본문 바로가기
iOS

[iOS] Timer, 특정 함수 반복 실행하기

by 책 읽는 개발자_테드 2021. 2. 10.
반응형

timeInterval에 원하는 시간(초), #selector에 반복할 함수를 입력한다.   

Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(testFunc), userInfo: nil, repeats: true)

 

  반복할 함수를 작성한다.

@objc func testFunc(){
     print("반복한다.")
}
반응형

댓글