Here is the code I am running in the Swift playground:
import Foundation
import AudioToolbox
var audioURL:NSURL = NSURL.fileURLWithPath("/path")
var audioFile:UnsafePointer<AudioFileID>
var audioCfUrl:CFURL = audioURL as CFURL
AudioFileOpenURL(audioCfUrl!, Int8(kAudioFileReadPermission), 0, &audioFile)
On the last line I am getting the error:
'NSURL' is not a subtype of CFURL
The error message might be misleading.
audioCfUrl!
is wrong because audioCfUrl
is not an optional.AudioFileID
variable.As already said in a (now deleted) answer, you don't have to cast the NSURL
to CFURL
:
let audioURL = NSURL.fileURLWithPath("/path")
var audioFile : AudioFileID = nil
let status = AudioFileOpenURL(audioURL, Int8(kAudioFileReadPermission), 0, &audioFile)
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