Help with SIGABRT Error

Discussion in 'iOS Programming' started by WhatsACode, Jul 3, 2014.

  1. WhatsACode macrumors newbie

    Joined:
    Jul 3, 2014
    #1
    Hi!
    I`m extremely new to programming in general, and I can't figure out this error. In the debugging area, it says

    "*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<FirstViewController 0x109339890> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key CalculateButton.'"

    If anyone could help, I would really appreciate it.
     
  2. PhoneyDeveloper macrumors 68040

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    This is one of the most asked questions of all time for iOS development

    https://www.google.com/search?hl=en...mages&tbs=&as_filetype=&as_rights=&gws_rd=ssl

    Anyway, you have a problem in your nib or storyboard. There once was an IBOutlet named CalculateButton that you've removed. You need to fix the issue in the nib so it doesn't reference this IBOutlet any more, or you need to add it back to FirstViewController.
     
  3. WhatsACode, Jul 3, 2014
    Last edited by a moderator: Jul 3, 2014

    WhatsACode thread starter macrumors newbie

    Joined:
    Jul 3, 2014
    #3
    I have an IBAction listed in my code and the button is still linked to it.
    https://drive.google.com/file/d/0B2nHSI6_HBAuMmRmRzRPdjNZU0E/edit?usp=sharing

    Here is my FirstViewController.h
    Code:
    #import <UIKit/UIKit.h>
    
    @interface FirstViewController : UIViewController {
        
        __weak IBOutlet UITextField *TextField1;
        __weak IBOutlet UITextField *TextField2;
        __weak IBOutlet UITextField *TextField3;
        __weak IBOutlet UILabel *GradeNeeded;
    }
    - (IBAction)CalculateButton:(id)sender;
    
    
    @end
    
    and my FirstViewController.m

    Code:
    #import "FirstViewController.h"
    
    @interface FirstViewController ()
    
    @end
    
    @implementation FirstViewController
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    	// Do any additional setup after loading the view, typically from a nib.
       
    }
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    - (IBAction)CalculateButton:(id)sender {
        
        float x = ([TextField1.text floatValue]);
        
        float y = ([TextField2.text floatValue]);
        
        float z = ([TextField3.text floatValue]);
        
        float answer = ((y)-(x*(1-z)))/z;
        
        GradeNeeded.text = [[NSString alloc] initWithFormat:@"%2.f"
                            
                            ,answer];
    }
    @end
    
    Does it need to be changed to an IBOutlet?
     
  4. PhoneyDeveloper macrumors 68040

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    Look at the connections in your nib. There is something wrong with the connection to that action. You may need to remove what's there and re-add it.

    The error message says that when trying to connect an outlet named CalculateButton that outlet didn't exist. You're right that it's an action not an outlet. For some reason it thinks you told it that there is an outlet of that name.

    BTW, use the code tag, not the quote tag for code. That's the button with the #. Then you won't get the unhappy faces in your code :(
     
  5. WhatsACode thread starter macrumors newbie

    Joined:
    Jul 3, 2014
    #5
    I figured it out. I had some duplicate connections or something like that with multiple names. Thank you so much PhoneyDeveloper for your help!
     

Share This Page