title: Segue doesn't work in macOS
body: <p>I have <code>NSSlider</code> in <code>ViewController</code> that must pass integer value to <code>SecondViewController</code> via segue of type <code>Show</code> and update a View every time I move it. So, moving slider I interactively shuffle images in <code>SecondViewController</code>'s window. </p>
  
  <p>I spent a week trying to implement such a behaviour of <code>NSSlider</code> but I failed. Maybe I made wrong connections in Interface Builder. I don't know. If you know any other method to make <code>NSSlider</code> work for shuffling images, tell me, please. </p>
  
  <p>See updated answer for detailed information.</p>
  
  <p>Really appreciate any help!!!</p>
  
  <p><strong>ViewController</strong></p>
  
  <pre><code>import Cocoa
  
  class ViewController: NSViewController {
  
      @IBOutlet weak var slider: NSSlider!
  
      @IBAction func passData(_ sender: NSSlider) {        
          func prepare(for segue: NSStoryboardSegue, sender: NSSlider?) {
              if segue.identifier!.rawValue == "SegueIdentifierForSecondVC" {
                  if let secondViewController = segue.destinationController as? SecondViewController {
                      secondViewController.imagesQuantity = slider.intValue 
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>SecondViewController</strong></p>
  
  <pre><code>import Cocoa
  
  class SecondViewController: NSViewController {
  
      var imagesQuantity: Int = 1
  
      override func viewWillAppear() {
          super.viewWillAppear()
  
          print(imagesQuantity)
      }
  }
  </code></pre>
  
  <p>But it doesn't work. What's wrong in my code? </p>
  
  <p>Any help appreciated.</p>
  
  <blockquote>
    <p><strong>UPDATED ANSWER</strong></p>
  </blockquote>
  
  <p><strong>VIEW CONTROLLER</strong></p>
  
  <pre><code>import Cocoa
  
  extension NSStoryboardSegue.Identifier {
      static let secondVC = NSStoryboardSegue.Identifier("SegueIdentifierForSecondVC")
  }
  
  class ViewController: NSViewController {
  
      @IBOutlet weak var slider: NSSlider!
  
      @IBAction func segueData(_ sender: NSSlider) {
          self.performSegue(withIdentifier: .secondVC, sender: slider)
      }
      override func prepare(for segue: NSStoryboardSegue, sender: Any?) {
          if segue.identifier! == .secondVC {
              if let secondViewController =
                  segue.destinationController as? SecondViewController {
                  secondViewController?.imagesQty = slider.integerValue 
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>SECOND VIEW CONTROLLER</strong></p>
  
  <pre><code>import Cocoa
  
  class SecondViewController: NSViewController {
  
      var imagesQty = 30  
  
      override func viewWillAppear() {
          super.viewWillAppear()
          //let arrayOfViews: [NSImageView] = [view01...view12]
  
          let url = URL(fileURLWithPath: NSHomeDirectory()).appendingPathComponent("Desktop/ArrayOfElements")
  
          do {
              let fileURLs = try FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys: nil, options: [.skipsHiddenFiles]).reversed()
              let photos = fileURLs.filter { $0.pathExtension == "jpg" }
  
              for view in arrayOfViews {
                  //"imagesQty" is here
                  let i = Int(arc4random_uniform(UInt32(imagesQty-1)))
                  let image = NSImage(data: try Data(contentsOf: photos[i]))
                  view.image = image
              }
          } catch {
              print(error)
          }
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/McJoS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/McJoS.png" alt="enter image description here"></a></p>