Search code examples
iosswiftxcodeuitextviewviewcontroller

UITextView object is not being recognized in new controller


I'm kind of new to Swift programming, so this question might look silly!

I have a new viewController named InfoViewController and I have connected it to the visual view controller in main.storyboard as the figure below:

As you can see, the view controller in main.storyboard is connected to InfoViewController.swift screenshot

However, when I insert the UITextView into the InfoViewController.swift, it does not recognize it as the following pic.

link of image

What is the problem, any help is highly appreciated 😊


Solution

  • You cannot access the outlet property on the from outside method. In viewDidLoad method you can easily access the myText outLet.

    override func viewDidLoad(){
        super.viewDidLoad()
        myText.text = "something new"
    }