得到错误:
错误:不能在不可变值上使用变异成员:'fromArray'是'let'常量
在以下代码中:
func removing (item: Int, fromArray: [Int]) -> [Int] {
for i in 0...fromArray.count-1 {
if fromArray[i] == item {
let index = i
fromArray.remove(at: index) // <-- error is here
}
}
return fromArray
}
var anarray : [Int] = [1, 2,3, 4 ,3]
var x = 3
removing(item: x, fromArray: anarray)
Run Code Online (Sandbox Code Playgroud) 我正在关注本教程:https : //miguesaldana.me/2017/03/13/how-to-create-a-soundcloud-like-waveform-in-swift-3/
我的代码如下。有一个例外:
错误域=com.apple.coreaudio.avfaudio Code=2003334207 “(null)” UserInfo={failed call=ExtAudioFileOpenURL((CFURLRef)fileURL, &_extAudioFile)}
let file = try! AVAudioFile(forReading: AudioLink) //Got Exception Here
let format = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: file.fileFormat.sampleRate, channels: file.fileFormat.channelCount, interleaved: false)
print(file.fileFormat.channelCount)
let buf = AVAudioPCMBuffer(pcmFormat: format!, frameCapacity: UInt32(file.length))
try! file.read(into: buf!)
// print("floatArray \(readFile.arrayFloatValues)\n")
//self.waveFormView.setNeedsDisplay()
Run Code Online (Sandbox Code Playgroud)