12

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

Santosh
  • 2,900
  • 1
  • 16
  • 16
Nishad
  • 203
  • 1
  • 2
  • 9

1 Answers1

36

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.

Rob
  • 415,655
  • 72
  • 787
  • 1,044