2016-07-01 9 views
7

Swift 3 용 CocoaPod를 만들려고합니다. CocoaPods가 NimbleQuick을 사용하고 있으며 해당 라이브러리가 아직 업데이트되지 않았기 때문에 repos를 포크하고 변환하려고합니다. 민첩한 프로젝트에서 Swift 3에서 setTimer가 사용되지 않았습니까?

이의 서명라는 함수입니다 :

setTimer(start: DispatchTime, interval: UInt64, leeway: UInt64) 

컴파일러 Cannot invoke 'setTimer' with an argument list of type '(start: DispatchTime, interval: UInt64, leeway: UInt64)'

private let pollLeeway: UInt64 = NSEC_PER_MSEC 
let interval = UInt64(pollInterval * Double(NSEC_PER_SEC)) 
asyncSource.setTimer(start: DispatchTime.now(), interval: interval, leeway: pollLeeway) 

모든은 SetTimer 방법이 사용되지 않습니다 자동 완성 보여 주지만에서 말한다 내가 무엇 found 그들은해서는 안됩니다.

대체품이 있습니까?

는 엑스 코드 8 베타 1에서는, 그 메소드의 서명은

답변

0

: 올바른 DispatchTimeDispatchTimeInterval 매개 변수를 연결하면

public func setTimer(start: DispatchTime, 
        interval: DispatchTimeInterval, 
        leeway: DispatchTimeInterval = default) 

은 컴파일하고 당신은 중단 경고 표시됩니다

'setTimer(start:leeway:)' is deprecated: replaced by 
instance method 'DispatchSourceTimer.scheduleOneshot(deadline:leeway:)' 

언제나 그렇듯이 Swift 클래스와 메소드를 command + 클릭하면 이러한 메소드가 선언 된 Swift 인터페이스 소스로 이동하게됩니다.

7

스위프트 3.0에서는

let timer = DispatchSource.makeTimerSource(flags: DispatchSource.TimerFlags(rawValue: UInt(0)), queue: DispatchQueue.global(qos: DispatchQoS.QoSClass.default)) 
    timer.scheduleRepeating(deadline: DispatchTime.init(uptimeNanoseconds: UInt64(100000)), interval: DispatchTimeInterval.seconds(1), leeway: DispatchTimeInterval.seconds(0)) 

을 대신 사용해야합니다, 그리고 그것은 나를

을위한 작업입니다