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 を変換できませんか? CGポイントへ
現在、userInfo を他の関数に渡して取得することはできないようです。