title: Passing CoreData Container from UITabBar to another VC
body: <p>i want to pass the container from my Tabbar to my VC, I tried to do it something like this, but does not work at all. How do I fix it?</p>
  <p>My VC</p>
  <pre><code>class FavVC: UIViewController {
      var container: NSPersistentContainer!
      
      
      override func viewDidLoad() {
          super.viewDidLoad()
          guard container != nil else { fatalError(&quot;This view needs a persistent container.&quot;) }
          NSLayoutConstraint.activate([
          ])
      }
  }
  </code></pre>
  <p>My Tabbar</p>
  <pre><code>class TabBar:UITabBarController {
      
      var container: NSPersistentContainer!
      
      @IBOutlet weak var TabBarContent: UITabBar!
      
      override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
          if let favVC = segue.destination as? FavVC {
              favVC.container = container
          }
         }
      
      override func viewDidLoad() {
          super.viewDidLoad()
          guard container != nil else { fatalError(&quot;This view needs a persistent container.&quot;) }
          print(&quot;it works!&quot;)
      }
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/elxDp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/elxDp.png" alt="enter image description here" /></a></p>