title: How to warn the user with alert, if he hasn't performed the right action?
body: <p>I have a photo camera application, which can scans also QR codes and read them. I also have a button which opens the link of the QR code when it is pressed. Would you please help me how to display an alert notification to the users who scan codes which are not working. At the moment when I scan a QR code which is fake the app crashes and stops working. I want to prevent that and display a notification message something like : "This QR code is not working please try another one".</p>
  
  <p>So far I have created this code:</p>
  
  <pre><code>func openJSON(_ Person: String)
  {
  let jsonData1 = (try? Data(contentsOf: URL(string: "\(transffered text)")!)) as Data!
  
  var error : NSError?
  let ReadableJSON1 = JSON ( data:jsonData1!, options: JSONSerialization.ReadingOptions.mutableContainers, error: nil )
  
  
  if (error != nil){
  
      let myAlert = UIAlertController(title: "Please try another QR", message: error?.localizedDescription, preferredStyle: .alert) 
      let okAction = UIAlertAction(title: "Ok", style: .default, handler: nil)
      myAlert.addAction(okAction)
      self.present(myAlert, animated: true, completion: nil)
  
      return
  }
  </code></pre>