2015-11-01 85 views
1

我試圖創建一個新的覆蓋FUNC當我得到這個錯誤:從它的父類方法不覆蓋任何方法方法不覆蓋任何方法從它的超

我已經嘗試刪除重寫部分但那隻會給我另一個錯誤。

override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) { 

    let touch : UITouch! = touches.anyObject() as! UITouch 

    location = touch.locationInView(self.view) 

    person.center = location 
} 

override func touchesMoved(touches: NSSet!, withEvent event: UIEvent!) { 

    let touch : UITouch! = touches.anyObject() as! UITouch 

    location = touch.locationInView(self.view) 

    person.center = location 

} 
+0

而另一個錯誤是...?另外,這個方法所用的對象的類型是什麼? – Fogmeister

+0

不同的錯誤消息,但在http://stackoverflow.com/questions/28771896/overrideding-method-with-selector-touchesbeganwithevent-has-incompatible-type相同的問題。 –

回答

5

正確的方法簽名是:

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { 

} 

override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) { 

}