title: How do I reload UIScrollView containing ViewControllers to add/remove view controllers
body: <p>I have a scrollView that contains a dynamic amount of WeatherViewControllers each displaying the weather data of a different city the user has saved. The user can segue from the WeatherViewControllers to a CityListViewController. Where they can add and remove cities from their list which in turn should add and remove WeatherViewControllers from the scrollView upon dismissing the CityListViewController, this is where I am running into a problem. </p>
  
  <p>Currently I am trying to use a protocol to call viewDidLoad in the scrollViewController upon dismissing the CityListViewController but am getting an error:</p>
  
  <blockquote>
    <p>Fatal error: Unexpectedly found nil while unwrapping an Optional
    value: file)</p>
  </blockquote>
  
  <p>when it gets to:   </p>
  
  <pre><code>let weatherScreen = storyboard!.instantiateViewController(identifier: "View Controller") as! ViewController
  </code></pre>
  
  <p><em>Side Note:</em> Upon initially opening the app the scrollView loads properly with all the correct WeatherViewControllers in the UIScrollView and the correct cities in the list. </p>
  
  <pre><code>class ScrollViewController: UIViewController, ScrollReloadProtocol {
  
      func reloadScrollView() {
  
          print("SCROLL RELOADED!!!!!*******")
          self.viewDidLoad()
      }
  
      @IBOutlet weak var totalScrollView: UIScrollView!
      var pages = [ViewController]()
      var x = 0
      var weatherScreensArray = [SavedCityEntity]()
      var weatherScreenStringArray = [String]()
      let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
      var horizString = "H:|[page1(==view)]"
  
      let defaults = UserDefaults.standard
  
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          //userDefaults used to keep track of which screen is which to put different cities on different viewControllers
          defaults.set(0, forKey: "screenNumber")
          //load cities to get number of cities saved
          loadCities()
  
          var views : [String: UIView] = ["view": view]
          //create all weatherWeatherControllers
          while x &lt;= weatherScreensArray.count {
  
              pages.append(createAndAddWeatherScreen(number: x))
              weatherScreenStringArray.append("page\(x+1)")
              views["\(weatherScreenStringArray[x])"] = pages[x].view
              let addToHoriz = "[\(weatherScreenStringArray[x])(==view)]"
              horizString.append(addToHoriz)
  
              x+=1
          }
  
          horizString.append("|")
  
          let verticalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "V:|[page1(==view)]|", options: [], metrics: nil, views: views)
          let horizontalConstraints = NSLayoutConstraint.constraints(withVisualFormat: horizString, options: [.alignAllTop, .alignAllBottom], metrics: nil, views: views)
  
          NSLayoutConstraint.activate(verticalConstraints + horizontalConstraints)
      }
  
      //Function to create and add weatherViewController
      func createAndAddWeatherScreen(number: Int) -&gt; ViewController {
  
              defaults.set(number, forKey: "screenNumber")
  
              let weatherScreen = storyboard!.instantiateViewController(identifier: "View Controller") as! ViewController
  
              weatherScreen.view.translatesAutoresizingMaskIntoConstraints = false
  
              totalScrollView.addSubview(weatherScreen.view)
  
              addChild(weatherScreen)
              weatherScreen.didMove(toParent: self)
  
          return weatherScreen
      }
  }
  </code></pre>