Post

Replies

Boosts

Views

Activity

how to resolve Cannot find 'XXXX' in scope
Hi im new at developing and i got 2 errors i can't seem to find an answer on google. here is my code and the errors are Cannot find 'self' in scope Cannot find 'present' in scope // // ViewController.swift // Diabell // // Created by Richard Klug on 14/04/2021. // import UIKit import MessageUI class ViewController: UIViewController {   override func viewDidLoad() {     super.viewDidLoad()     // Do any additional setup after loading the view.   }       @IBAction func emailbButtonTapped( sender: Any) {    showMailComposer()   } }   func showMailComposer() {     guard MFMailComposeViewController.canSendMail() else{       return     }     let composer = MFMailComposeViewController()     composer.mailComposeDelegate = self     composer.setToRecipients(["richard.klug@diabell.se"])     composer.setSubject("Diabell App Help")     composer.setMessageBody("Fyll i vad du behöver hjälp med", isHTML: false)     present(composer, animated: true)       }   extension ViewController: MFMailComposeViewControllerDelegate {     func mailComposeController( controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {       if let _ = error {         controller.dismiss(animated: true)         return       }       switch result {       case .cancelled:         print ("Cancelled")       case .failed:         print ("Failed to send")       case .saved:         print ("Saved")       case .sent:         print ("Email Sent")       }       controller.dismiss(animated: true)     } }
2
0
1.8k
Apr ’21
Cannot find 'application' in scope
i get 2 of these errors ""Cannot find 'application' in scope"" what am i doing wrong or why is it not in scope? // // ViewController.swift // Diabell App // // Created by Richard Klug on 23/04/2021. // import UIKit import MessageUI class ViewController: UIViewController, MFMailComposeViewControllerDelegate {  override func viewDidLoad() {   super.viewDidLoad()   // Do any additional setup after loading the view.  }     //Function Email Bottom Left     @IBAction func Mail(_ sender: Any) {   showMailComposer()  }     func showMailComposer() {    guard MFMailComposeViewController.canSendMail() else{     return    }    let composer = MFMailComposeViewController()    composer.mailComposeDelegate = self    composer.setToRecipients(["richard.klug@diabell.se"])    composer.setSubject("Diabell App Help")    composer.setMessageBody("Fyll i vad du behöver hjälp med", isHTML: false)    present(composer, animated: true)  }      //Funktion Call Bottom Right       @IBAction func btnCallClick(_ sender: UIButton) {     if let phoneURL = URL(string: "tel://+46706106310"){       if application.canOpenUrl(phoneURL){         application.open(phoneURL, [:], completionHandler: nil)       }else{       }   }    } }
4
0
4.5k
Apr ’21