title: Setting UIImageView.image with valid UIImage creates "nil" error in swift
body: <p>I am trying to set the image property on a UIImageView.  When I use a UIImage to set the .image property it throws this error every time:</p>
  
  <blockquote>
    <p>"unexpectedly found nil while unwrapping an Optional value"</p>
  </blockquote>
  
  <p>The problem is that my UIImage is not nil.  </p>
  
  <p>Here is the code where I am setting the UIImage</p>
  
  <pre><code>func setPhotosForNewsItem(photoArray:[Photo]) {
      println("Image Count: " + String(photoArray.count))
      var image:UIImage = photoArray[0].photo
      println(image.description)
      self.newsImage.image = image
  }
  </code></pre>
  
  <p>Here is the console output:</p>
  
  <blockquote>
    <p>Image Count: 2 
    UIImage: 0x7fdd93c5cdd0, {1115, 1115} 
    fatal error:
    unexpectedly found nil while unwrapping an Optional value (lldb)</p>
  </blockquote>
  
  <p>I am able to use the Quick Look tool in xCode on my supposedly nil UIImage and see the photo that I am trying to use.  Why would I be throwing a nil error when my UIImage is clearly not nil?</p>
  
  <p>UPDATE::</p>
  
  <p>It seems that I am not properly storing the UIImage in my array.  Here is where I download my images and store them to my array for unpacking later.</p>
  
  <pre><code>var relatedPhotos:[PFObject] = relations as! [PFObject]
                              //println(relations!)
                              var photoArray:[Photo] = [Photo]()
  
                              for photo in relatedPhotos {
                                  var newPhoto = Photo()
                                  var photoFile:PFFile = photo.objectForKey("photo") as! PFFile
                                  newPhoto.object = photo
                                  newPhoto.objectID = photo.objectId!
      photoFile.getDataInBackgroundWithBlock({(imageData: NSData?, error: NSError?) -&gt; Void in
                                          if (error == nil) {
  
                                              newPhoto.photo = UIImage(data:imageData!)!
                                              //println(newPhoto.photo)
                                              photoArray.append(newPhoto)
  
                                              if photoArray.count == relatedPhotos.count {
  
                                                  if newObject is FieldReport {
                                                      var report = newObject as! FieldReport
                                                      report.photos = photoArray
                                                      updatedReports.append(report)
                                                      //println("Report Count 1: " + String(updatedReports.count))
                                                  }
                                                  else {
                                                      var report = newObject as! Feature
                                                      report.photos = photoArray
                                                      updatedReports.append(report)
                                                  }
  
                                                  if updatedReports.count == objects.count {
  
  
                                                      self.delegate?.fieldReports(updatedReports)
                                                  }
                                              }
  
                                          }
                                      })
  }
  </code></pre>
  
  <p>I know that this works to download and display the photo as I have just used it successfully to do so.  To me that means I am not storing the UIImage properly.  Is there a different way I should be storing these image files? </p>