title: Swift 3 load image from local directory
body: <p>I'm new to iOS dev and cannot figure out how to load an image in an imageView from a local directory.
  I use imagePickerController to pick an image, get its info, then use this information to display the image in the imageView.</p>
  
  <p>Here is the code to pick the image and its info dictionary:</p>
  
  <pre><code>func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
          let image             = info[UIImagePickerControllerOriginalImage] as! UIImage
  
          let imageUrl          = info[UIImagePickerControllerReferenceURL] as! NSURL
          let imageName         = imageUrl.lastPathComponent
          let documentDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first!
          let photoURL          = NSURL(fileURLWithPath: documentDirectory)
          let localPath         = photoURL.appendingPathComponent(imageName!)!
  
          imagesList.append(localPath)
  
          picker.dismiss(animated: true, completion: nil)
      }
  </code></pre>
  
  <p>Then, and here is where I'm looking for some help, I want to use either localPath or imageUrl to load the image in another imageView but cannot figure out how.
  I tried </p>
  
  <pre><code>func changeImage(_ sender: Any) {
          if imagesList.count &gt; 0 {
              let imageUrlPath = imagesList[indexList]
              let urlString: String = imageUrlPath.absoluteString
  
              imageView.image = UIImage(contentsOfFile: urlString)
  
              indexList = (indexList + 1) % imagesList.count
          }
      }
  </code></pre>
  
  <p>But I cannot have something working.
  Any idea how I can achieve that?</p>
  
  <p>Thank you for your help.</p>