0

I am new to ios programming,I am having viewcontroller inside navigation controller in storyboard,in that viewcontroller i have tableview items,so onclick of item i have to present some viewcontroller which is xib viewcontroller,i tried with some code i am getting exception.

    code:

         -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
                ThirdController *detailViewController = [[ThirdController alloc] initWithNibName:@"ThirdController" bundle:nil];

                [self.navigationController pushViewController:detailViewController animated:YES];

        }

exception:
SampleNaviationController[2499:84098] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ThirdController 0x7c02d9d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key sendResponse.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00b12a14 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x005d3e02 objc_exception_throw + 50
    2   CoreFoundation                      0x00b12631 -[NSException raise] + 17
    3   Foundation                          0x002691bc -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
    4   Foundation                          0x001c383a _NSSetUsingKeyValueSetter + 115
    5   Foundation                          0x001c37bf -[NSObject(NSKeyValueCoding) setValue:forKey:] + 295
    6   UIKit                               0x0106506d -[UIViewController setValue:forKey:] + 85
    7   Foundation                          0x001f801d -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 384
    8   UIKit                               0x012d8cb4 -[UIRuntimeOutletConnection connect] + 132
    9   libobjc.A.dylib                     0x005e800c -[NSObject performSelector:] + 62
    10  CoreFoundation                      0x00a42f51 -[NSArray makeObjectsPerformSelector:] + 273
    11  UIKit                               0x012d734e -[UINib instantiateWithOwner:options:] + 2102
    12  UIKit                               0x0106cabc -[UIViewController _loadViewFromNibNamed:bundle:] + 429
    13  UIKit                               0x0106d4f4 -[UIViewController loadView] + 189
    14  UIKit                               0x0106d900 -[UIViewController loadViewIfRequired] + 154
    15  UIKit                               0x01074406 -[UIViewController __viewWillAppear:] + 114
    16  UIKit                               0x010975b9 -[UIViewController(UIContainerViewControllerProtectedMethods) beginAppearanceTransition:animated:] + 202
    17  UIKit                               0x010a99cc -[UINavigationController _startCustomTransition:] + 1389
    18  UIKit                               0x010bb769 -[UINavigationController _startDeferredTransitionIfNeeded:] + 803
    19  UIKit                               0x010bcada -[UINavigationController __viewWillLayoutSubviews] + 68
    20  UIKit                               0x01298c4a -[UILayoutContainerView layoutSubviews] + 252
    21  UIKit                               0x00f6e008 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 810
    22  libobjc.A.dylib                     0x005e8059 -[NSObject performSelector:withObject:] + 70
    23  QuartzCore                          0x0492680a -[CALayer layoutSublayers] + 144
    24  QuartzCore                          0x0491a4ee _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
    25  QuartzCore                          0x0491a352 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
    26  QuartzCore                          0x0490ce8b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
    27  QuartzCore                          0x04940e03 _ZN2CA11Transaction6commitEv + 561
    28  QuartzCore                          0x04942674 _ZN2CA11Transaction17flush_transactionEv + 50
    29  UIKit                               0x00ed2dfa _afterCACommitHandler + 197
    30  CoreFoundation                      0x00a2bffe __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    31  CoreFoundation                      0x00a2bf5e __CFRunLoopDoObservers + 398
    32  CoreFoundation                      0x00a218dc __CFRunLoopRun + 1340
    33  CoreFoundation                      0x00a210e6 CFRunLoopRunSpecific + 470
    34  CoreFoundation                      0x00a20efb CFRunLoopRunInMode + 123
    35  GraphicsServices                    0x041c0664 GSEventRunModal + 192
    36  GraphicsServices                    0x041c04a1 GSEventRun + 104
    37  UIKit                               0x00ea1bfa UIApplicationMain + 160
    38  SampleNaviationController           0x001017ba main + 138
    39  libdyld.dylib                       0x03184a21 start + 1
    40  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
skyshine
  • 2,767
  • 7
  • 44
  • 84
  • We can't read your mind or see your computer. You have to tell us: _What_ exception are you getting? – matt Oct 08 '16 at 19:20
  • 1
    So this has nothing to do with the code you showed. The problem is that your xib is improperly configured. It has a `sendResponse` outlet, but your ThirdViewController has no `sendResponse` property. – matt Oct 08 '16 at 19:23
  • i understood ,i removed connection it is working – skyshine Oct 08 '16 at 19:28
  • Possible duplicate of [What does this mean? "'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X"](http://stackoverflow.com/questions/3088059/what-does-this-mean-nsunknownkeyexception-reason-this-class-is-not-key-v) – NobodyNada Oct 08 '16 at 21:39

1 Answers1

0

You have no sendResponse property in your ThirdViewController; hence the crash.

Here's my guess as to how that came about. When you configured the button in your xib, you made sendResponse an outlet. You probably wanted it to be an action.

matt
  • 515,959
  • 87
  • 875
  • 1,141