I'm using Back4app as Parse server I'm trying to stream audio from Prase everything works fine , but if I click on any index (except index 0) on tableview I got error "fatal error: unexpectedly found nil while unwrapping an Optional value"
I don't know why when I click on Index 0 it work fine but any other index I got error !
func grabSong() {
let SongQuery = PFQuery(className: "Songs")
SongQuery.getObjectInBackground(withId:iDArray[SelectedSongNumber!] ,block: { (object : PFObject?, error : Error?) -> Void in
if let AudioFileURLTemp : PFFile = object?.value(forKey: "SongFile") as? PFFile {
print(AudioFileURLTemp)
audioP = AVPlayer(url: NSURL(string: AudioFileURLTemp.url!) as! URL)
audioP.play()
}
})
}
I got the error on this line:
audioP = AVPlayer(url: NSURL(string: AudioFileURLTemp.url!) as! URL)