In my iOS project I have this file:
import UIKit
protocol ViewController {
static func instantiate() -> Self
}
extension ViewController {
static func instantiate() -> Self {
let fullName = NSStringFromClass(self)
let className = fullName.componentsSeparated(by: ".")[1]
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.mainBundle)
let controller = storyboard.instantiateViewController(withIdentifier: className) as! Self
return controller
}
}
The in my controller file I have this:
@IBObject public class RootViewController: UITableViewController, ViewController {
. . .
}
Shouldn’t it recognize the default implementation of the instantiate method? It’s giving an error on the class declaration saying the static func instantiate() not implemented.