NetNewsWire/Frameworks/RSXML/RSXMLTests/Resources/TimerSearch.txt

31 lines
489 B
Plaintext
Raw Normal View History

2017-05-22 22:06:02 +02:00
class SomeViewController: NSViewController {
@IBOutlet weak var textField: NSTextField
private var NSTimer: fetchDataTimer?
private var currentText: String? {
didSet {
invalidateTimer()
if currentText.length > 3 {
restartTimer()
}
}
}
func textDidChange(notification: NSNotification) {
currentText = textField.stringValue
}
func invalidateTimer() {
if let timer = timer {
if timer.isValid {
timer.invalidate()
}
self.timer = nil
}
}
}