2016-07-01 37 views
7

Swift 3 için bir CocoaPod oluşturmaya çalışıyorum. Çünkü CocoaPods, Nimble ve Quick kullanıyor ve bu kütüphaneler henüz güncellenmedi, ben repo'ları çürütttüm ve dönüştürmeye çalışıyorum. Çevik projede Swift 3'te setTimer kullanımdan kaldırıldı mı?

orada imzasıyla adında bir fonksiyonudur:

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

derleyici 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) 

tüm SetTimer yöntemleri kullanımdan kaldırılmıştır otomatik tamamlama gösterileri, fakat diyor found ne yapmamalılar.

Bir değiştirme var mı?

Xcode 8 beta 1'de bu yöntemin imzadır

cevap

0

: Doğru DispatchTime ve DispatchTimeInterval parametreleri takarsanız

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

derlemek olacak ve bir kullanımdan kaldırılması uyarı görür:

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

Her zaman olduğu gibi, bu Swift sınıflarına ve yöntemlerine + komutunu tıklayarak bu yöntemlerin bildirildiği Swift arabirim kaynaklarına ulaşırsınız.

7

Swift 3.0 size

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)) 

yerine kullanmalıdır ve bu benim

için bir iş
İlgili konular