Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Method does not override any method from its superclass" Swift 3 [duplicate]

Tags:

ios

swift

swift3

This code is swift 2

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    let playerViewController = segue.destination as! PlayerViewController
    playerViewController.videoID = channelsDataArray[selectedVideoIndex]["videoID"] as! String   
}

Errors "Method does not override any method from its superclass"

Please solution for swift 3

like image 914
Nishad Avatar asked Oct 11 '16 18:10

Nishad


1 Answers

In Swift 3 and later, it is prepare(for:sender:) and the second parameter is Any:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if let destination = segue.destination as? PlayerViewController {
        destination.videoID = channelsDataArray[selectedVideoIndex]["videoID"] as! String
    }
}

In the future, if you temporarily comment out your method and start to type prepare, code completion will show you the proper method signature.

like image 108
Rob Avatar answered Oct 31 '22 17:10

Rob