I have a table of custom NSTableCellViews that contain embedded NSProgressIndicators and NSButtons that I would like to update both immediately after a click, and periodically, on a timer. This is a sample of my code thus far:
func sound(sound: NSSound, didFinishPlaying aBool: Bool) {
pbNowPlaying.doubleValue = sound.currentTime
if aBool == true {
self.btnPlay.stringValue = "Play"
self.btnPlay.state = NSOffState
self.pbNowPlaying.doubleValue = 0
}
self.needsDisplay = true
}
This (and other code where self.needsDisplay = true is set) does not seem to update the view. When I manually reload the table data, the progress bar moves (having been bound to the NSSounds .currentTime value), but the button text/state does not change.
Any advice?
Coding using Swift, Xcode 6.4, OS X 10.10.4
Well, I feel rather dumb, but for anyone else who might be running into the same problem: To modify the text on an NSButton, you need to change the .title property, not the .stringValue property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With