title: How to call a function that is located in another class in Swift?
body: <p>I try to make the Label in iOS app to show <code>"asdf"</code>  in label using 2 view controller.</p>
  
  <p>I try to run <code>testA()</code> function but it shows out an error: <code>ViewController.swift:15:9: Use of unresolved identifier 'testA'</code></p>
  
  <h3>My initial code:</h3>
  
  ViewController.swift
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      override func viewDidLoad() {
          super.viewDidLoad()
          testA()
      } 
  }
  </code></pre>
  
  In another controller (TestViewController):
  
  <pre><code>import UIKit
  
  class TestViewController: UIViewController {
      @IBOutlet weak var testLabel: UILabel!
  
      func testA() {
          testLabel.text = "asdf"
      }
  
  }
  </code></pre>
  
  <p>and my Main.storyboard is linked to TestViewController class</p>
  
  <p>I did a little bit search on google and I came to try out inheritance and It did not shows the error, but the function was not called.</p>
  
  <h2>I try to use Inheritance method:</h2>
  
  In View Controller (ViewController.swift):
  
  <pre><code>import UIKit
  
  class ViewController: TestViewController {
  
      override func viewDidLoad() {
          super.viewDidLoad()
          testA()
      }
  }
  </code></pre>
  
  <p>The error was resolved, but the label did not change to <code>asdf</code></p>
  
  <p>How do I make my <code>ViewController.swift</code> able to call the function <code>testA()</code> that is located in another controller <code>TestViewController.swift</code> ?</p>