0
I’m studying about Clean-Swift and VIP architecture, and I’m having trouble doing the route part to call a Viewcontroller by the button. It may seem simple, but I don’t have much experience with Swift. I’m not using Storyboard, but Xib file If anyone can help me and explain where I might be missing I’d appreciate!
Homeviewcontroller
class HomeViewController: UIViewController
{
var routerPassData = FistRouter()
override func viewDidLoad()
{
super.viewDidLoad()
self.view.backgroundColor = .blue
let newBtn = UIButton()
newBtn.setTitle("btn", for: .normal)
newBtn.titleLabel?.font = UIFont(name: "AppleSDGothicNeo-Thin",
size: 50)
newBtn.addTarget(routerPassData.self, action: #selector(routerPassData.teste), for: .touchUpInside)
newBtn.frame = CGRect(x: 15, y: 54, width: 300, height: 500)
newBtn.setTitleColor(.black, for: .normal)
self.view.addSubview(newBtn)
}
}
Homerouter
class HomeRouter: NSObject
{
@objc func teste() {
let pass = Bundle.main.loadNibNamed("secView", owner: self, options:
nil)?.first as? secViewController
pass?.viewDidLoad()
}
When I put this test Func in the Viewcontroller I have the expected result which is to call the other Viewcontroller, only when I separate it from this error
this class is not key value coding-compliant for the key view.'
Where can I be missing?