0

New to this, so please bear with me. I have set up an IBAction to allow for a URL to open in Safari when the button is tapped. The URL opens successfully, but then I receive error in AppDelegate.swift: unrecognized selector sent to instance. When troubleshooting, I set up the same code and same IBAction in the initial view controller, and i did NOT get the error, and was able to return back to the app (from Safari) successfully. It seems this is happening only in one specific View Controller, which is not the initial VC. I'm hoping this is just a rookie and/or trivial mistake. Thanks for any help :)

enter image description here

import UIKit

class WeekDetailViewController: UIViewController {
    @IBOutlet weak var lessonCompleteBtn: UIButton!
    @IBOutlet weak var stackOButton: UIButton!
    @IBOutlet weak var stackExchButton: UIButton!
    @IBOutlet weak var redditButton: UIButton!
    @IBOutlet weak var facebookButton: UIButton!

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func stackOButton(_ sender: Any) {
        UIApplication.shared.open(URL(string: "https://www.google.com")! as URL, options: [:], completionHandler: nil)
    }
}

Here is the problem:

enter image description here

koen
  • 5,383
  • 7
  • 50
  • 89
  • Welcome to SO. Please read [ask] and take a [tour]. And add a [example] explaining what you currently do and what doesn't work. – koen May 06 '20 at 18:55
  • Your code has `stackOButton` but the error says `stackOButtonPressed`. Those names need to be the same. – koen May 06 '20 at 19:39
  • Thank you - like I said, rookie mistake. Screenshot attached of what was causing the problem. Thank you @koen :) – mattthew_james May 06 '20 at 19:50
  • We've all made that mistake. Glad I could help. – koen May 06 '20 at 19:54

0 Answers0