[英]Cannot convert value of type ('string: String)' to expected argument type 'URL'
When I run the following code, I get the error cannot convert value of type ('string: String)' to expected argument type 'URL'
当我运行以下代码时,出现错误
cannot convert value of type ('string: String)' to expected argument type 'URL'
var recorder = AVAudioRecorder(url: (string: URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("tmp.caf").absoluteString), settings: [
AVFormatIDKey : Int(kAudioFormatAppleIMA4),
AVSampleRateKey : Int(44100),
AVNumberOfChannelsKey : Int(1),
AVLinearPCMBitDepthKey : Int(16),
AVLinearPCMIsBigEndianKey : false,
AVLinearPCMIsFloatKey : false
])
This should work: 这应该工作:
let recorder = AVAudioRecorder(url: URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("tmp.caf"), settings: [
AVFormatIDKey : Int(kAudioFormatAppleIMA4),
AVSampleRateKey : Int(44100),
AVNumberOfChannelsKey : Int(1),
AVLinearPCMBitDepthKey : Int(16),
AVLinearPCMIsBigEndianKey : false,
AVLinearPCMIsFloatKey : false
])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.