【发布时间】:2020-07-16 20:11:25
【问题描述】:
我有循环遍历双精度数组并从双精度和数组索引创建 CGPoint 的代码。
但是,我不知道如何将生成的 CGPoints 放入数组中。这是我的代码:
var points = [CGPoint].self//The compiler is okay with this but I don't know what self really means. Without self it giver error 'expected member name or constructor call after type name'
var i:Int = 0
while i < closingprices.count {
let mypoint = CGPoint(x: Double(i+1),y: closingprices[i])
// points += mypoint //This throws error:Binary operator '+=' cannot be applied to operands of type '[CGPoint].Type' and 'CG
i+=1
}
如何将 CGPoints 放入数组中?
【问题讨论】: