title: Facing issue in UIScrollview in Swift
body: <p>I am new to ios development.I am working on Swift programming.I am trying to create a scrollview but getting </p>
  
  <p><code>"fatal error: unexpectedly found nil while unwrapping an Optional value"</code></p>
  
  <p>every time. I used optional value too in the below code.</p>
  
  <p>Here is my code </p>
  
  <pre><code>   class ViewController: UIViewController
      {
       var imagelist=["apple.jpeg","pears.jpeg","banana.jpeg","grapes.jpeg","mango.jpeg"]
       var itemNames = ["Apple", "Pear", "Banana", "Grapes", "Mango"]
  
      var scrollView: UIScrollView!
      var yPos: Float?
      yPos!=0
  
      override func viewDidLoad()
      {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
  
          createScrollview()
      }
  
      func createScrollview()
      {
  
          scrollView = UIScrollView(frame: view.bounds)
  
          for var index = 0; index &lt; self.imagelist.count; ++index
          {
              var fruitsImgView:UIImageView!
              fruitsImgView.frame=CGRectMake(0,CGFloat(yPos!), 320, 200)
              fruitsImgView.image=UIImage(named: self.imagelist[index])
              scrollView.addSubview(fruitsImgView)
               yPos!=yPos!+200
          }
  
          scrollView.contentSize = CGSizeMake(scrollView.frame.size.width  * CGFloat(imagelist.count), scrollView.frame.size.height)
  
          view.addSubview(scrollView)
  
      }
  
      }
  </code></pre>
  
  <p>I am unable to get the issue.Please help me if any one worked on it.
  Thanks in advance.</p>