I want to know how to access an @IBOutlet declared in a class from another class
for example, I have a class named myfirstview
class MyFirstView: UIViewController {
@IBOutlet var lblred: UILabel! = UILabel()
}
I want to change the text of the lblred
from another class named MySecondView
which is written in another .swift
file:
class MySecondView: UIViewController {
func modify() {
let mfv = MyFirstView()
mfv.lblred.text = "Hello"
}
}
But nothing happens.
I have connected lblred
with a storyboard label. I have searched a lot about this on the web but I can't find the one which can solve my problem. Please help me solve this problem.
Thank you.