斯威夫特的步伐(从:,到:,由:)导致“无法调用”

我是第一次使用
Swift的步伐.然而,由于我无法使其工作,因此第一次即将成为最后一次:

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.
}
点赞