title: How to to check image nil when access to camera and press cancel on camera
body: <p>How to check  image nil when access to camera and press cancel on camera</p>
  
  <p>I’m tested<br>
  First step </p>
  
  <ol>
  <li>Press take photo button 
  
  <ul>
  <li>access camera
  
  <ol start="2">
  <li>Press cancel  I’m get value on output panel  
  
  <ul>
  <li>Check image take photo ==> Optional(UIImagePickerController: 0x107879a00) </li>
  </ul></li>
  <li>Press save button photo on project<br>
  I’m getting value nil 
  
  <ul>
  <li>Fatal error: Unexpectedly found nil while unwrapping an Optional value 2019-07-05 08:52:24.667938+0700 MyProject[2307:786209] Fatal error: Unexpectedly found nil while unwrapping an Optional value</li>
  </ul></li>
  </ol></li>
  </ul></li>
  </ol>
  
  <p>I’m tested<br>
  the second step </p>
  
  <ol>
  <li><h2>Take photo</h2>
  
  2.press use photo on the ​camera
  
  <ul>
  <li>Take photo press use photo  on camera 
  
  <blockquote>
    <p>Check image take photo ==> Optional(UIImagePickerController: 0x10286ca00)</p>
  </blockquote></li>
  </ul></li>
  </ol>
  
  <p>I want to check case cancel on camera and go back press save button on the project</p>
  
  <blockquote>
    <p>How to fix….this case
    My code below</p>
  </blockquote>
  
  <p>Take photo </p>
  
  <pre><code> @IBAction func takePhotoReturnOfSealButton(_ sender: UIButton) {
          imagePickerStoreListReturnSealLock = UIImagePickerController()
          imagePickerStoreListReturnSealLock.delegate = self
          imagePickerStoreListReturnSealLock.sourceType = .camera
          present(imagePickerStoreListReturnSealLock,animated: true, completion: nil)
          print("Check image take photo ==&gt; \(String(describing: imagePickerStoreListReturnSealLock))")
      }//takePhotoReturnOfSealButton
  </code></pre>
  
  <p>Save photo</p>
  
  <pre><code>@IBAction func saveImageToDevice(_ sender: UIButton) {
          //Save photo to device not success have nil value
          if(imagePickerStoreListReturnSealLock == nil){
              showAlert(title: "No Have Photo", message: "Please take photo")
              print("Check image cannot save ==&gt; \(String(describing: imagePickerStoreListReturnSealLock))")
          }else{
  //          Save photo to device success
              UIImageWriteToSavedPhotosAlbum(showImageTakePhotoReturnOfSeal.image!, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)
              print("Check image Save to device ==&gt; \(String(describing: showImageTakePhotoReturnOfSeal))")
          }
      }//saveImageToDevice
  </code></pre>