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 другой функции, а затем получить ее.