How to make slider value change object or function?
<p>I am new to the site and Swift so any feedback on question technique is gratefully received.</p>

<p>I am trying to make the value of a slider change both the audio that it being played and the text label (or image).</p>

<p>I have created my outlets:</p>

<pre><code>@IBOutlet weak var audioSlider: UISlider!
@IBOutlet weak var audioValue: UILabel!
</code></pre>

<p>And my action:</p>

<pre><code>@IBAction func audioSliderValueChanged(sender: UISlider) {
    var currentValue = (sender.value)
    audioValue.text = (StringInterpolationConvertible: audioValue))
</code></pre>

<p>All connected to one slider. I am unsure of how to approach this issue - would an if else work?</p>

<p><strong>EDIT: Han Yong Code:</strong></p>

<p>There was already a 'do' for other sounds within the app using AVFoundation. I imported Foundation (AVFoundation was already imported)</p>

<p>I have added:</p>

<pre><code>@IBOutlet weak var audioSlider: UISlider!
@IBOutlet weak var audioValue: UILabel!
var audioSliderPlayer:AVAudioPlayer = AVAudioPlayer()
var currentTime: Double {
    get {
        return CMTimeGetSeconds(audioSliderPlayer.currentTime)
    }
    set {
        let newTime = CMTimeMakeWithSeconds(newValue, 1)
        audioSliderPlayer.seekToTime(newTime, toleranceBefore: kCMTimeZero, toleranceAfter: kCMTimeZero)
    }
}
</code></pre>

<p>And added the following after the do function (within viewDidLoad):</p>

<pre><code>    {timeObserverToken = audioSliderPlayer.addPeriodicTimeObserverForInterval(interval, queue: dispatch_get_main_queue()) {
        [weak self] time in
        self?.timeSlider.value = Float(CMTimeGetSeconds(time))
        }}


}
</code></pre>

<p>I have updated the action:</p>

<pre><code>@IBAction func timeSliderDidChange(sender: UISlider) {
    currentTime = Double(sender.value)
}
</code></pre>

<p>However, I am still having issues with errors. Also, how would I be able to specify which audio it plays dependent on value?</p>