내 앱에 백그라운드 프로세스가 있습니다. 코드는 다음과 같습니다.ios9의 배경 타이머
@available(iOS 10.0, *)
func startTimer() {
timer2?.invalidate()
timer2 = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true, block: { (t) in
if UIApplication.shared.applicationState == .background {
NSLog("tic background \(UIApplication.shared.backgroundTimeRemaining)")
if UIApplication.shared.backgroundTimeRemaining < 10 {
}
}
})
timer2?.fire()
}
그러나 iOS10에서만 작동합니다. 이전 버전의 iOS 용으로 다시 쓸 수있는 방법이 있습니까?
iOS9의 문제가 무엇입니까? – shallowThought
'scheduledTimer (withTimerInterva : repeatedats : 블록)'은 iOS 10 이상에서만 사용 가능합니다. –
참조. http://stackoverflow.com/a/24007862/1457385 – shallowThought