Q:

Calling a function from one ViewController to another

I have two functions that i would like to call in another ViewController.  I don't want to write the same code in the other Viewcontroller. I have tried creating a ViewController object and call the two methods this but keep getting crashes. I have also tried extending the UIViewController but no luck. How can i go on about
import UIKit
import WebKit

class PrivacyPolicyController: UIViewController, WKUIDelegate {

    var webView: WKWebView!

    override func loadView() {
        super.loadView()
        createWebView()
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        loadURL(url: "https://www.apple.com")
    }

    func loadWebView() {
        let webConfiguration = WKWebViewConfiguration()
        webView = WKWebView(frame: .zero, configuration: webConfiguration)
        webView.uiDelegate = self
        view = webView

    }

    func loadURL(url: String) {
        guard let myURL = URL(string: url) else { return }
        let myRequest = URLRequest(url: myURL)
        webView.load(myRequest)
    }
}

I wanna call loadURL and loadWebView functions in this ViewController
import UIKit
import WebKit
class TermsAndConditionsController: UIViewController{

    override func loadView() {
        super.loadView()
    }

    override func viewDidLoad() {
        super.viewDidLoad()

    }
}

The ViewController where actions are performed 
import UIKit

class WelcomeViewController: UIViewController {

    @IBAction func termsAndConditionsTapped(_ sender: UIButton) {
        let termsAndConditions = TermsAndConditionsController()
        self.navigationController?.pushViewController(termsAndConditions, animated: true)
    }

    @IBAction func privacyPolicyTapped(_ sender: UIButton) {
        let privacyPolicy = PrivacyPolicyController()
        self.navigationController?.pushViewController(privacyPolicy, animated: true)
    }

}

A:

As I wrote in a comment, use the same viewcontroller for both the Privacy Policy and T&C:
import UIKit
import WebKit

class MyWebViewController: UIViewController {

    var webView: WKWebView!
    override func viewDidLoad() {
        super.viewDidLoad()
    }

    func loadWebView() {
        let webConfiguration = WKWebViewConfiguration()
        self.webView = WKWebView(frame: .zero, configuration: webConfiguration)
        self.view.addSubview(self.webView)
        webView.translatesAutoresizingMaskIntoConstraints = false
        webView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor).isActive = true
        webView.topAnchor.constraint(equalTo: self.view.topAnchor).isActive = true
        webView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor).isActive = true
        webView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true
    }

    func loadURL(url: String) {
        guard let myURL = URL(string: url) else { return }
        let myRequest = URLRequest(url: myURL)
        if (self.webView == nil) {
            self.loadWebView()
        }
        self.webView.load(myRequest)
    }

}

Then:
import UIKit

class MakeItHappenViewController: UIViewController {

    @IBAction func termsAndConditionsTapped(_ sender: UIButton) {
        let termsAndConditions = MyWebViewController()
        self.navigationController?.pushViewController(termsAndConditions, animated: true)
        termsAndConditions.loadURL("http://someurl.com")
    }

    @IBAction func privacyPolicyTapped(_ sender: UIButton) {
        let privacyPolicy = MyWebViewController()
        self.navigationController?.pushViewController(privacyPolicy, animated: true)
        privacyPolicy.loadURL("http://someotherurl.com")
    }

}

