Hello
I created a class NSObject, in this class I create a button, when the user touch this button I need to show a ViewController, but I have the error message:
Value of type 'CarregarMenu' has no member 'navigationController'
On this line
self.navigationController!.pushViewController(vc, animated: true)
This is the code:
import Foundation
import UIKit
class CarregarMenu: NSObject {
......
@objc func btnPeidosFinalizadosAction(sender: UIButton!){
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "PedidosFinalizadosController")
self.navigationController!.pushViewController(vc, animated: true) // this line shows error
}
......
override init() {
super.init()
}
}
How can I fix it? This class is generic and can be called on everywhere on my app