Swift 的步幅(从:,到:,通过:)导致 "cannot invoke"
Swift's stride(from: , to: , by: ) causing "cannot invoke"
我是第一次使用 Swift 的步幅。但是 first 即将成为最后一个,因为我无法让它工作:
let boundingBox = createdShape.frame //=SKShapeNode
stride(from: Int(boundingBox.minX), to: Int(boundingBox.maxX), by: 10) {
结果是:
Cannot invoke 'stride' with an argument list of type '(from: Int, to: Int, by: Int, () -> ())'
我做错了什么?
语法应为:
let boundingBox = createdShape.frame //=SKShapeNode
for x in stride(from: Int(boundingBox.minX), to: Int(boundingBox.maxX), by: 10) {
// TODO: Use x here.
}
我是第一次使用 Swift 的步幅。但是 first 即将成为最后一个,因为我无法让它工作:
let boundingBox = createdShape.frame //=SKShapeNode
stride(from: Int(boundingBox.minX), to: Int(boundingBox.maxX), by: 10) {
结果是:
Cannot invoke 'stride' with an argument list of type '(from: Int, to: Int, by: Int, () -> ())'
我做错了什么?
语法应为:
let boundingBox = createdShape.frame //=SKShapeNode
for x in stride(from: Int(boundingBox.minX), to: Int(boundingBox.maxX), by: 10) {
// TODO: Use x here.
}