Michal Klimczak
04/29/2021, 3:24 PMdo {
try AVAudioPlayer(contentsOf: url)
} catch {
// handle exception
}
In Kotlin Native it's signature is
public constructor(contentsOfURL: platform.Foundation.NSURL, error: CPointer<ObjCObjectVar<NSError?>>?)
How do you handle error here?Sam
04/29/2021, 7:57 PMMichal Klimczak
04/30/2021, 5:19 AMSam
04/30/2021, 2:03 PMval player: AVAudioPlayer
memScoped {
val errorPtr: ObjCObjectVar<NSError?> = alloc<ObjCObjectVar<NSError?>>()
player = AVAudioPlayer(url, errorPtr.ptr)
println(errorPtr.value) //Will be null if the call succeeds.
}
Michal Klimczak
04/30/2021, 3:49 PMSam
04/30/2021, 5:58 PM