我喜歡爲我的函數調用更改數組值。Swift - 更改函數調用的數組值
代碼爲我ViewController2調用一個函數計算
class ViewController2: UIViewController , UITableViewDelegate, UITableViewDataSource {
var springDisplacement : [Float] {return calculate(forceView2, stiffView2, springNumView2) }
}
代碼函數計算
public func calculateBoundary (f:[Float], s:[Float], n:NSInteger) -> (forceBound1:Float, forceBound2: Float, displacement:[Float]) {
println("\nForces in the array are")
for rows in 0...n{
if(rows==0||rows==n)
{ f[rows] = 0.0 }
println(f[rows])
}
}
我有一個錯誤: '@lValue $ T5' 不等同於'浮動',當我想改變我的[行] = 0.0
任何建議?
'VAR springDisplacement:[浮點] {回報計算(forceView2,stiffView2,springNumView2)}'給我錯誤:'inout [(Float)]'不能轉換爲'[Float]'。我已經聲明我的f和forceView2是float類型的數組。 – 2015-02-12 06:05:08