override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
let touch = touches.anyObject() as UITouch
let touchLocation = touch.locationInNode(self)
timer = NSTimer.scheduledTimerWithTimeInterval(0.5, target: self, selector: "shoot", userInfo: touchLocation, repeats: true) // error 1
}
func shoot() {
var touchLocation: CGPoint = timer.userInfo // error 2
println("running")
}
我正在尝试创建一个定期运行的计时器,它将触摸点(CGPoint)作为 userInfo 传递给 NSTimer,然后在 shoot() 函数中访问它。但是,现在我收到一条错误消息
1) 调用中的额外参数选择器
2) 无法转换表达式类型 AnyObject?到 CGPoint
现在我似乎无法将 userInfo 传递给另一个函数然后检索它。