App is throwing an NSException for a variable that does not exist in this view controller?

StackOverflow https://stackoverflow.com/questions/23234638

  •  07-07-2023
  •  | 
  •  

Question

The Problem:

My app has started crashing when I try to launch the Solution Submittal View controller, it throws the following exception which refers to a previous version's variable "projectTitleTextField" which has been replaced with "projectTitleSearchBar." I do not understand why it is throwing an exception because I replaced the variable and the linked object with a search bar then cleaned/built the project. Please help, thanks.

The Thrown Exception:

2014-04-22 23:51:50.515 AbleConnections[11005:60b] 
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: 
'[<ABLSolutionSubmittalViewController 0x9952510> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key projectTitleTextField.'
*** First throw call stack:
(
    0   CoreFoundation                      0x018091e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x015748e5 objc_exception_throw + 44
    2   CoreFoundation                      0x01898fe1 -[NSException raise] + 17
    3   Foundation                          0x01234d9e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
    4   Foundation                          0x011a11d7 _NSSetUsingKeyValueSetter + 88
    5   Foundation                          0x011a0731 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
    6   Foundation                          0x01202b0a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
    7   UIKit                               0x004eb1f4 -[UIRuntimeOutletConnection connect] + 106
    8   libobjc.A.dylib                     0x015867de -[NSObject performSelector:] + 62
    9   CoreFoundation                      0x0180476a -[NSArray makeObjectsPerformSelector:] + 314
    10  UIKit                               0x004e9d4d -[UINib instantiateWithOwner:options:] + 1417
    11  UIKit                               0x003526f5 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
    12  UIKit                               0x00352e9d -[UIViewController loadView] + 302
    13  UIKit                               0x003530d3 -[UIViewController loadViewIfRequired] + 78
    14  UIKit                               0x00379345 -[UINavigationController _layoutViewController:] + 39
    15  UIKit                               0x0037985b -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 235
    16  UIKit                               0x00379953 -[UINavigationController _startTransition:fromViewController:toViewController:] + 78
    17  UIKit                               0x0037a8cc -[UINavigationController _startDeferredTransitionIfNeeded:] + 645
    18  UIKit                               0x0037b4e9 -[UINavigationController __viewWillLayoutSubviews] + 57
    19  UIKit                               0x004bc0d1 -[UILayoutContainerView layoutSubviews] + 213
    20  UIKit                               0x002a3964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
    21  libobjc.A.dylib                     0x0158682b -[NSObject performSelector:withObject:] + 70
    22  QuartzCore                          0x03c6045a -[CALayer layoutSublayers] + 148
    23  QuartzCore                          0x03c54244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    24  QuartzCore                          0x03c540b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
    25  QuartzCore                          0x03bba7fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
    26  QuartzCore                          0x03bbbb85 _ZN2CA11Transaction6commitEv + 393
    27  QuartzCore                          0x03bbc258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
    28  CoreFoundation                      0x017d136e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    29  CoreFoundation                      0x017d12bf __CFRunLoopDoObservers + 399
    30  CoreFoundation                      0x017af254 __CFRunLoopRun + 1076
    31  CoreFoundation                      0x017ae9d3 CFRunLoopRunSpecific + 467
    32  CoreFoundation                      0x017ae7eb CFRunLoopRunInMode + 123
    33  GraphicsServices                    0x037e95ee GSEventRunModal + 192
    34  GraphicsServices                    0x037e942b GSEventRun + 104
    35  UIKit                               0x00234f9b UIApplicationMain + 1225
    36  AbleConnections                     0x000047bd main + 141
    37  libdyld.dylib                       0x01e3c701 start + 1
    38  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Code for the ABLSolutionSubmittalViewController class:

// ABLSolutionSubmittalViewController.m
// AbleConnections
// Created by Padft12Laws2Liv on 4/21/14.
// Copyright (c) 2014 ABLE LLC. All rights reserved.

#import "ABLSolutionSubmittalViewController.h"

@interface ABLSolutionSubmittalViewController ()

@property (weak, nonatomic) IBOutlet UISearchBar *projectTitleSearchBar;
//In previous version ^this line read UITextField *projectTitleTextField;
@property (weak, nonatomic) IBOutlet UITextField *countryTextField;
@property (weak, nonatomic) IBOutlet UITextField *solutionTitleTextField;
@property (weak, nonatomic) IBOutlet UITextView *solutionDescriptionTextView;
@property (weak, nonatomic) IBOutlet UITextView *requiredResourcesTextView;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *saveButton;

@end

@implementation ABLSolutionSubmittalViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if (sender != self.saveButton) return;
    if (self.solutionTitleTextField.text.length > 0) {
        self.solutionSubmission = [[ABLSolutionSubmission alloc] init];
        self.solutionSubmission.PROJECT_TITLE = self.projectTitleSearchBar.text;
        self.solutionSubmission.COUNTRY_OF_ORIGIN = self.countryTextField.text;
        self.solutionSubmission.SOLUTION_TITLE = self.solutionTitleTextField.text;
        self.solutionSubmission.solutionDescription = self.solutionDescriptionTextView.text;
        self.solutionSubmission.requiredResources = self.requiredResourcesTextView.text;
    }
}

@end
Was it helpful?

Solution

Check in the xib projectTitleTextField is linked to some one or not. If it is there then there should be warning there so please remove it. Do the clean and build the project. Also try with deleting the app from simulator also.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top