0

I created a drop-down menu with 2 buttons in the menu that when pressed, segue you to a different page. I have set up the information to segue to the "Expense Report" page using the ExpenseBTN, but when I run the simulation and try to click the ExpenseBTN it gives me a “Thread 1: signal SIGABRT” error. How do I solve this? Attached is my code

import UIKit

class SecondViewController: UIViewController {
    
    
    @IBOutlet var Buttons: [UIButton]!
    
    @IBAction func ExpenseBTNpressed(_ sender: UIButton) {
        self.performSegue(withIdentifier: "ToExpenseReport", sender: self)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
        
    @IBAction func HandleSelection(_ sender: UIButton) {
        Buttons.forEach { (button) in
            UIView.animate(withDuration: 0.3, animations: {
                button.isHidden = !button.isHidden
                self.view.layoutIfNeeded()

            })
        }
    }

    @IBAction func ButtonTapped(_ sender: UIButton) {
        
    }
}

Resulting in:

2021-09-01 13:46:45.408799-0400 mmmmm[8779:945391] Failed to set () user defined inspected property on (UIView): [<UIView 0x7f81507102e0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key .
2021-09-01 13:46:51.142036-0400 mmmmm[8779:945391] -[mmmmm.SecondViewController ExpenseBTN:]: unrecognized selector sent to instance 0x7f815060e910
2021-09-01 13:46:51.148679-0400 mmmmm[8779:945391] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[mmmmm.SecondViewController ExpenseBTN:]: unrecognized selector sent to instance 0x7f815060e910'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010e3851e6 __exceptionPreprocess + 294
    1   libobjc.A.dylib                     0x000000010a7eb031 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010e406784 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   UIKit                               0x000000010b2b56db -[UIResponder doesNotRecognizeSelector:] + 295
    4   CoreFoundation                      0x000000010e307898 ___forwarding___ + 1432
    5   CoreFoundation                      0x000000010e307278 _CF_forwarding_prep_0 + 120
    6   UIKit                               0x000000010b0883e8 -[UIApplication sendAction:to:from:forEvent:] + 83
    7   UIKit                               0x000000010b2037a4 -[UIControl sendAction:to:forEvent:] + 67
    8   UIKit                               0x000000010b203ac1 -[UIControl _sendActionsForEvents:withEvent:] + 450
    9   UIKit                               0x000000010b202a09 -[UIControl touchesEnded:withEvent:] + 580
    10  UIKit                               0x000000010b0fd0bf -[UIWindow _sendTouchesForEvent:] + 2729
    11  UIKit                               0x000000010b0fe7c1 -[UIWindow sendEvent:] + 4086
    12  UIKit                               0x000000010b0a2310 -[UIApplication sendEvent:] + 352
    13  UIKit                               0x000000010b9e36af __dispatchPreprocessedEventFromEventQueue + 2796
    14  UIKit                               0x000000010b9e62c4 __handleEventQueueInternal + 5949
    15  CoreFoundation                      0x000000010e327bb1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    16  CoreFoundation                      0x000000010e30c4af __CFRunLoopDoSources0 + 271
    17  CoreFoundation                      0x000000010e30ba6f __CFRunLoopRun + 1263
    18  CoreFoundation                      0x000000010e30b30b CFRunLoopRunSpecific + 635
    19  GraphicsServices                    0x0000000110c7da73 GSEventRunModal + 62
    20  UIKit                               0x000000010b087057 UIApplicationMain + 159
    21  mmmmm                               0x0000000109eda1c7 main + 55
    22  libdyld.dylib                       0x000000010f566955 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
Rob
  • 392,368
  • 70
  • 743
  • 952
Austin
  • 9
  • 4
  • 1
    @Rob, I see a circle with a dot inside of it next to IBOutlet – Austin Sep 01 '21 at 17:24
  • 1
    Show us the full error message. Your SIGABRT was almost certainly accompanied by some messages in the console which, while cryptic at first glance, actually include critical diagnostic information. It generally will tell you _why_ you got the SIGABRT. Edit your post to include this information. – Rob Sep 01 '21 at 17:26
  • @Rob I just copied and pasted the error page it took me to. The SIGABRT error appears on the line class AppDelegate: UIResponder, UIApplicationDelegate { – Austin Sep 01 '21 at 17:29
  • 1
    See where's the console: https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/debugging_tools.html If it's hidden, show it, and copy/paste the content of it here. There should be as said an error message containing useful debug informations... – Larme Sep 01 '21 at 17:36
  • @Rob yeah I don't man I still can't get it to work. Thanks anyways, it's fine if you can't figure it out – Austin Sep 01 '21 at 17:41
  • 1
    I'm sure we can figure it out ... you just need to provide the relevant info as requested. – flanker Sep 01 '21 at 17:44
  • 1
    @Austin We can't figure out what's wrong because it's missing the debug information. Debugging is not magic. It's mostly reading messages, error messages and interpret them, like a doctor with symptoms. If a doctor can't get answers from the patient about where's the pain, he can't do anything (since ausculting would be testing your code which we don't have access to). At least, take a screenshot of your Xcode when it crashes? copy/paste the WHOLE content of your Console output? – Larme Sep 01 '21 at 17:46
  • @Rob Is this what you need? See updated post – Austin Sep 01 '21 at 17:49
  • @Larme I am a beginner, that's why I am on here lol. I am self learning through youtube videos etc., I don't know everything about swift and what each window is called. That's why I am on stack overflow right now. – Austin Sep 01 '21 at 17:50
  • 3
    I know, but that's why we really insisted on getting the error message in console. The error is clear now. Did you named the method before `ExpenseBTN( sender:)`, but renamed it `ExpenseBTNpressed(_ sender:)` afterwards? Well, you connected with the Storyboard with the old name, renamed it by code, but then didn't redo the connection in storyboard by deleting the old one, and reconnecting it to the new method. – Larme Sep 01 '21 at 17:53
  • @Austin the left panel is called the "Project Navigator", right right panel is called the "Attributes inspector", the debug panel is called the debug panel. I think. Or the "console". You can bring it up using `Shift` + `Command` + `Y`. – aheze Sep 01 '21 at 17:53
  • Btw there are also some conventions that you should start getting used to: `HandleSelection` should be renamed to `handleSelection`. All variables and functions should start with a lowercase letter. Pretty much the only capitalized names are for classes, structs, and enums – aheze Sep 01 '21 at 17:54
  • @Austin, visit this https://learnappmaking.com/sigabrt-xcode-swift/#:~:text=Further%20Reading-,What%20Does%20%E2%80%9CThread%201%3A%20Signal%20SIGABRT%E2%80%9D%20Mean%3F,means%20your%20app%20has%20crashed%E2%80%A6 – Protocol Sep 01 '21 at 17:54
  • @Larme so you're saying I just need to restart the project over from scratch? – Austin Sep 01 '21 at 18:00
  • No, you don't have to. You did some drag & drop with the UI, no? See https://stackoverflow.com/questions/42078140/unrecognized-selector-sent-to-instance delete the old connection (from the button to `ExpenseBTN:`, and redo it with the new one... – Larme Sep 01 '21 at 18:03
  • 1
    1) Press ⇧⌘F 2) Enter or paste *ExpenseBTN* 3) Press Return 4) Click the search result to navigate to the storyboard 5) Delete the dead connection 6) Reconnect it to your renamed IBAction. – vadian Sep 01 '21 at 18:09

0 Answers0