title: delegation (while creating sideMenu, delegate? returns nil)
body: <p>guys.
  I'm asking for help. It seems a very easy task, but I can solve it for the whole day.
  I'm trying to create a side menu using container view. When a user presses More button(barButtonItem), the whole view slide to the right and menu table appears. I know how to make it using Notifications. But I would like to solve it through delegation. Here is my storyboard.
  <a href="https://i.stack.imgur.com/hlikj.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>and code:</p>
  
  <pre><code>import UIKit
  
  class RootViewController: UIViewController, SideMenuDelegate {
  
      @IBOutlet weak var leading: NSLayoutConstraint!
  
      var sideMenuIsOpen = false
      var sideMenu: MainViewController?
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          sideMenu?.delegate = self
      }
  
      func openSideMenu() {
          toggleSideMenu()
      }
  
      func toggleSideMenu() {
          if sideMenuIsOpen {
              leading.constant = 0
          } else {
              leading.constant = 240
          }
      }
  }
  </code></pre>
  
  <p>and:
          import UIKit</p>
  
  <pre><code>protocol SideMenuDelegate {
      func openSideMenu()
  }
  
  class MainViewController: UIViewController {
  
      var delegate: SideMenuDelegate?
  
      @IBAction func toggleSideMenu(_ sender: UIBarButtonItem) {
          if let delegateUnwrapped = delegate {
              delegateUnwrapped.openSideMenu()
          } else {
              print("nil")
          }
      }
      override func viewDidLoad() {
          super.viewDidLoad()
  
          BackgroundImageView.createBackground(insideView: self, image: .mainViewBackground)
  
      }   
  </code></pre>
  
  <p>}</p>
  
  <p>Thank you!</p>