hmm now the app just crashes when i press the call button i think i still got something in the code?
2021-04-23 14:47:35.995353+0200 Diabell App[79068:6184787] -[Diabell_App.ViewController Call:]: unrecognized selector sent to instance 0x104e095f0
2021-04-23 14:47:35.996463+0200 Diabell App[79068:6184787] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Diabell_App.ViewController Call:]: unrecognized selector sent to instance 0x104e095f0' First throw call stack:
(0x1ae4a19d8 0x1c2824b54 0x1ae3b1bbc 0x1b0d40d30 0x1ae4a401c 0x1ae4a5f8c 0x1b0d12f38 0x1b06a8184 0x1b06a84c8 0x1b06a6e00 0x1b0d4dbc0 0x1b0d4f4e8 0x1b0d2ab0c 0x1b0dad078 0x1b0db1818 0x1b0da8afc 0x1ae421bf0 0x1ae421af0 0x1ae420e38 0x1ae41b3e0 0x1ae41aba0 0x1c5180598 0x1b0d0c2f4 0x1b0d11874 0x1c1b98b54 0x104990114 0x10499008c 0x104990158 0x1ae0f9568)
libc++abi.dylib: terminating with uncaught exception of type NSException** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Diabell_App.ViewController Call:]: unrecognized selector sent to instance 0x104e095f0'
terminating with uncaught exception of type NSException
(lldb)
//
// 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) {
let application = UIApplication.shared //-
if let phoneURL = URL(string: "tel://+46706106310") {
if application.canOpenURL(phoneURL) { //- `canOpenURL`, not `canOpenUrl`
application.open(phoneURL, options: [:], completionHandler: nil) //- `options:` needed
} else {
//...
}
}
}
}
Post
Replies
Boosts
Views
Activity
I think i got something wrong when i did this? the app crashes as soon as i press the call button on my phone?
//
// 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 callButtonClicked(_ sender: Any) {
}
private func callNumber(phoneNumber:String) {
if let phoneCallURL = URL(string: "tel://\(+46706106310)") {
let application:UIApplication = UIApplication.shared
if (application.canOpenURL(phoneCallURL)) {
application.open(phoneCallURL, options: [:], completionHandler: nil)
}
}
}
}
I would like some help with that KMT! can you see what i did wrong in my code the app crashes when i press the call button
//
// 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 callButtonClicked(_ sender: Any) {
}
private func callNumber(phoneNumber:String) {
if let phoneCallURL = URL(string: "tel://\(+46706106310)") {
let application:UIApplication = UIApplication.shared
if (application.canOpenURL(phoneCallURL)) {
application.open(phoneCallURL, options: [:], completionHandler: nil)
}
}
}
}
Thanks!