【发布时间】:2014-08-01 06:47:26
【问题描述】:
我正在尝试使用 Swift 处理一个应用程序,但使用数组时遇到以下错误:
fatal error: Array index out of range
当应用程序为索引 0 处的数组赋值时会出现这种情况:
class DrawScene: SKScene {
init(size: CGSize) {
super.init(size: size)
}
var line = SKShapeNode()
var path = CGPathCreateMutable()
var touch: UITouch!
var pts = [CGPoint]()
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
/* Called when a touch begins */
touch = touches.anyObject() as UITouch!
self.pts[0] = touch.locationInNode(self) <-- Error appears here
drawLine()
}
一些想法? (我使用的是 xcode 6 Beta 4)
【问题讨论】: