need help troubleshooting buttons on another viewcontroller

Discussion in 'iOS Programming' started by theprizerevealed, Oct 26, 2016.

  1. theprizerevealed macrumors regular

    Feb 26, 2016
    I am experiencing trouble solving this problem: I have created another viewcontroller and started writing code in it. I created the viewcontroller by dragging the view controller from the Object Library onto the main.storyboard. Then I created the associated viewcontroller.swift by using Xcode File > New > File > Cocoa Touch Class.

    Now to debug I created a new project, I added a button to the new viewcontroller and added an IBOutlet for that button and an IBAction for that button to the new viewcontroller's .swift file. Then to test it I added code to change the button title when the button is pressed. That worked fine.

    But in another project I'm trying to do the same thing but it won't work. To debug, I remove all the code except IBOutlet and IBAction for a single button. Then I input code into the IBAction to simply change the button label. When tapped it crashes the program. What could be the cause ? thanks
  2. theprizerevealed thread starter macrumors regular

    Feb 26, 2016
    I solved this problem by going to View>Utilities>Connection Inspector and deleting all the connections and reconnecting everything to the view controller
  3. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    Usually you don't need to use the nuclear option to fix problems like this. When you say the program "crashed" that often means that a runtime exception was thrown. The debugger console shows information from the nice engineers at Apple to help you figure out the problem. You'll need to learn to read that information. Next time you might want to post it so someone else can help you figure it out. The usual problem is that there's a connection to a view that no longer exists or some other invalid IBOutlet or IBAction connection in the storyboard.
  4. theprizerevealed thread starter macrumors regular

    Feb 26, 2016
    I see what you mean now. If I go to the Connections Inspector and examine each of those little text bubbles and compare what IBActions work and which don't then I was able to see a new problem and fix it - much better and less work than the 'nuclear option' !

Share This Page

3 October 26, 2016