Kimkelly Rapiz
Kimkelly Rapiz

Reputation: 1

What's wrong with my code? Method cannot be an @objc

What's wrong with my code? I keep getting this error, I don't know why it says method cannot be an @objc override because the type of parameter 2 cannot be represented in Objective-C.

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    // Get the new view controller using segue.destinationViewController.
    // Pass the selected object to the new view controller.

    let vc = segue.destinationViewController as! MovieViewController
    if let indexPath = self.tableView.indexPathForSelectedRow{
        let item = TableData[indexPath.row]
        vc.senddMovie = item
    }
}

Upvotes: 0

Views: 1270

Answers (1)

SRTWarrior
SRTWarrior

Reputation: 43

it's because of the "Any?" in the function signature. it is a swift only type and can not be bridged to Objective-C.

see this answer discussing the issue : https://stackoverflow.com/a/26366289/4264079

Upvotes: 1

Related Questions