music app contain track slider to control the music playback ,this is the code i used in objective-c to set the value of the slider
TrackSlider.maximumValue = Player.duration;
TrackSlider.minimumValue = 0;
Player.currentTime = TrackSlider.value;
now in swift and the new xCode this code is no more working i got this error
'NSTimeInterval' is not convertible to 'Float'
'Float' is not convertible to 'NSTimeInterval'
is there a way to convert the slider value(float) to the player.currentTime(NSTimeInterval) or the opposite
Let's consider this example:
var interval: NSTimeInterval = 12.48
let myFloat: Float32 = 12.67
interval = myFloat //Compile time error: 'Float32' is not convertible to 'NSTimeInterval'
interval = Double(myFloat) // works as NSTimeInterval is a typealias for Double
If your case is similar to this example, you need to cast your TrackSlider.value
.