I am trying to access a variable from a different class. What am I doing wrong?
class ViewController: UIViewController {
var restaurantName = "Test"
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func btnClicked(_ sender: Any) {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()){
let pop = popView()
self.view.addSubview(pop)
}
}
}
here is the class I am trying to access it from:
class popView: UIView{
fileprivate let titleLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = UIFont.systemFont(ofSize:28, weight: .bold)
label.textAlignment = .center
//label.text = "TITLE"
label.text = restaurantName
return label
}()
}
How can I access the 'restaurantName' variable in the 'popView' class?
thanks in advance