简体   繁体   English

无法将类型(“字符串:字符串”)的值转换为预期的参数类型“ URL”

[英]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.

相关问题 无法转换'String?'类型的值 预期的参数类型'URL' - Cannot convert value of type 'String?' to expected argument type 'URL' 无法将类型'String?.Type'的值转换为预期的参数类型'String?' - Cannot convert value of type 'String?.Type' to expected argument type 'String?' 无法将类型“ [String:Any]”的值转换为预期的参数类型“ String” - Cannot convert value of type '[String : Any]' to expected argument type 'String' 无法转换'String!'类型的值预期的参数类型错误 - Cannot convert value of type 'String!' to expected argument type error 无法将“NSMutableDictionary”类型的值转换为预期的参数类型“[String: AnyObject]?” - Cannot convert value of type 'NSMutableDictionary' to expected argument type '[String: AnyObject]?' 无法将“String”类型的值转换为预期的参数类型“AnyObject?” - Cannot convert value of type 'String' to expected argument type 'AnyObject?' ios无法将类型“()”的值转换为预期的参数类型“字符串”,迅速3 - ios Cannot convert value of type '()' to expected argument type 'String' swift 3 无法将类型'((String !, NSError!)->()'的值转换为预期的参数类型'GGLInstanceIDTokenHandler!' - Cannot convert value of type '(String!, NSError!) -> ()' to expected argument type 'GGLInstanceIDTokenHandler!' 无法在Swift 3中将字符串类型的值转换为预期的参数类型int - cannot convert value of type string to expected argument type int in swift 3 无法将类型“x”的值转换为预期的参数类型“[String: Any]” - Cannot convert value of type 'x' to expected argument type '[String : Any]'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM