terminate called after throwing an instance of 'NSException' error - objective-c

Can you please help me, my application worked well, but when i did a modification on it, (i don't remember what kind of modification) i got this message in the console:
[Session started at 2010-11-21 17:15:36 -0500.]
2010-11-21 17:15:37.472 ITMFR[3942:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UICustomObject 0x6a50d90> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key window.'
*** Call stack at first throw:
(
0 CoreFoundation 0x021f2b99 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0234240e objc_exception_throw + 47
2 CoreFoundation 0x021f2ad1 -[NSException raise] + 17
3 Foundation 0x000320f3 _NSSetUsingKeyValueSetter + 135
4 Foundation 0x00032061 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x004b070a -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x02168d0f -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x004af121 -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x004b0eb5 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x002bc402 -[UIApplication _loadMainNibFile] + 172
10 UIKit 0x002bd31c -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 198
11 UIKit 0x002c73ec -[UIApplication handleEvent:withNewEvent:] + 1958
12 UIKit 0x002bfb3c -[UIApplication sendEvent:] + 71
13 UIKit 0x002c49bf _UIApplicationHandleEvent + 7672
14 GraphicsServices 0x02ad2822 PurpleEventCallback + 1550
15 CoreFoundation 0x021d3ff4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
16 CoreFoundation 0x02134807 __CFRunLoopDoSource1 + 215
17 CoreFoundation 0x02131a93 __CFRunLoopRun + 979
18 CoreFoundation 0x02131350 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x02131271 CFRunLoopRunInMode + 97
20 UIKit 0x002bcc6d -[UIApplication _run] + 625
21 UIKit 0x002c8af2 UIApplicationMain + 1160
22 ITMFR 0x00003eb8 main + 102
23 ITMFR 0x000028e9 start + 53
24 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
please, HELP ME!!

From the crash report, I would guess that the change you made was to the nib / xib file in Interface builder, specifically in binding a value to a button / control. Check the Inspector for all of your UI controls to make sure that any Button Bindings that are bound to Shared User Defaults Controller have controller key values, and not something else.

This happened to me because I forgot #synthesize.
#synthesize window;
In my view controller.

Related

IOS Application Terminating at main file itself NSException

2015-09-21 10:57:48.696 Kip Up[4707:140538] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x00ce6746 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x005b9a97 objc_exception_throw + 44
2 CoreFoundation 0x00b9bce1 -[__NSArrayM insertObject:atIndex:] + 881
3 CoreFoundation 0x00b9b941 -[__NSArrayM addObject:] + 65
4 UIKit 0x0134bc3b -[UIView(UIViewGestures) addGestureRecognizer:] + 210
5 Kip Up 0x000c0c1e -[ViewController viewDidLoad] + 414
6 UIKit 0x0141dd54 -[UIViewController loadViewIfRequired] + 771
7 UIKit 0x0141e045 -[UIViewController view] + 35
8 UIKit 0x0130fe35 -[UIWindow addRootViewControllerViewIfPossible] + 66
9 UIKit 0x013102fc -[UIWindow _setHidden:forced:] + 287
10 UIKit 0x013105f8 -[UIWindow _orderFrontWithoutMakingKey] + 49
11 UIKit 0x0131e966 -[UIWindow makeKeyAndVisible] + 80
12 UIKit 0x012b3e88 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3217
13 UIKit 0x012b73d2 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1639
14 UIKit 0x012d08ee __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke + 59
15 UIKit 0x012b5ffa -[UIApplication workspaceDidEndTransaction:] + 155
16 FrontBoardServices 0x04490c9e __37-[FBSWorkspace clientEndTransaction:]_block_invoke_2 + 71
17 FrontBoardServices 0x0449072f __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 54
18 FrontBoardServices 0x044a2d7c __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 30
19 CoreFoundation 0x00c08050 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 16
20 CoreFoundation 0x00bfd963 __CFRunLoopDoBlocks + 195
21 CoreFoundation 0x00bfd7bb __CFRunLoopRun + 2715
22 CoreFoundation 0x00bfca5b CFRunLoopRunSpecific + 443
23 CoreFoundation 0x00bfc88b CFRunLoopRunInMode + 123
24 UIKit 0x012b59b2 -[UIApplication _run] + 571
25 UIKit 0x012b90b6 UIApplicationMain + 1526
26 Kip Up 0x000c229a main + 138
27 libdyld.dylib 0x03278ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Please check if your root view controller UIViewController connections are intact. It usually happens due to broken link on the Interface Builder. If you are using Storyboards, make sure you haven't hooked up duplicate referencing outlets. Also ensure that you are importing AppDelegate.h.
Again there could be n number of reason for this crash. Please use exception or symbolic break point to come to a conclusion.

Application crash on UIButton click : iphone

I have a View base iphone application
I add a NSObject class AddNewContact and take its object in IB
AddNewContact.h
#import <Foundation/Foundation.h>
#interface AddNewContact : NSObject {
}
-(IBAction)abc:(id)sender;
#end
AddNewContact.m
#import "AddNewContact.h"
#implementation AddNewContact
-(IBAction)abc:(id)sender{
NSLog(#"this is test");
}
#end
I bind a UIButton action to abc: on clicking the button application crashes, even NSLog is also not logged
but if I bind the button action to other classes function then it working ok
Crash Log
2011-06-08 15:40:30.368 myApp[5466:207] -[NSCFString abc:]: unrecognized selector sent to instance 0x6b7b1c0
2011-06-08 15:40:30.416 myApp[5466:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString abc:]: unrecognized selector sent to instance 0x6b7b1c0'
*** Call stack at first throw:
(
0 CoreFoundation 0x02ad9b99 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x02c2940e objc_exception_throw + 47
2 CoreFoundation 0x02adb6ab -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x02a4b2b6 ___forwarding___ + 966
4 CoreFoundation 0x02a4ae72 _CF_forwarding_prep_0 + 50
5 UIKit 0x0039e7f8 -[UIApplication sendAction:to:from:forEvent:] + 119
6 UIKit 0x00429de0 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x0042c262 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
8 UIKit 0x0042ae0f -[UIControl touchesEnded:withEvent:] + 458
9 UIKit 0x003c23d0 -[UIWindow _sendTouchesForEvent:] + 567
10 UIKit 0x003a3cb4 -[UIApplication sendEvent:] + 447
11 UIKit 0x003a89bf _UIApplicationHandleEvent + 7672
12 GraphicsServices 0x0306a822 PurpleEventCallback + 1550
13 CoreFoundation 0x02abaff4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
14 CoreFoundation 0x02a1b807 __CFRunLoopDoSource1 + 215
15 CoreFoundation 0x02a18a93 __CFRunLoopRun + 979
16 CoreFoundation 0x02a18350 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x02a18271 CFRunLoopRunInMode + 97
18 GraphicsServices 0x0306900c GSEventRunModal + 217
19 GraphicsServices 0x030690d1 GSEventRun + 115
20 UIKit 0x003acaf2 UIApplicationMain + 1160
21 myApp 0x00001fa4 main + 102
22 myApp 0x00001f35 start + 53
)
terminate called after throwing an instance of 'NSException'
Can anybody tell me where I am wrong
Thanks
Amit Battan
You will be releasing your AddNewContact view controller, the view is still in the superview but the viewController is released, the button tries to call 'abc' on AddNewContact controller which no longer exists...

Weird problems with program and debugger in xcode

Okay, I have a program that I'm trying to test on my iPad. I have it all set up so that the app is able to get on the iPad just fine, but running it on the iPad is a different story.
Now, the thing is, my program was working fine on the debug configuration, but now it won't work on that, either. It's strange, because before I was able to get to a certain part of the program before it crashed, but now it's crashing before that.
The debugger is hardly helping. When I use the debugger window, it will step into one line of code, and then suddenly jump back to another line of code.
I really don't understand what's going on. The crash is now occuring in a root view controller that I have set up, called 'FunctionMachineViewController. Here's the code for when it crashes:
-(IBAction)startOnePlayer:(id)sender
{
GameViewController* GameView = [[GameViewController alloc] initWithNibName:nil bundle:nil];
[GameView isOnePlayer:YES withLevel:startLevelNumber];
[self presentModalViewController:GameView animated:YES];
}
GameViewController is supposed to initialize just fine, but the debugger shows it as uninitialized. I even tried setting it up in the header file instead, but the problem still happens. Has anyone else come across these problems? Any help would be greatly appreciated!
EDIT: Here's what the console says when it crashes:
[Session started at 2011-06-02 21:46:10 -0700.]
2011-06-02 21:46:13.309 FunctionMachine[5033:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<GameViewController 0x4b2a890> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Yminus2.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dd55a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f29313 objc_exception_throw + 44
2 CoreFoundation 0x00dd54e1 -[NSException raise] + 17
3 Foundation 0x0003d677 _NSSetUsingKeyValueSetter + 135
4 Foundation 0x0003d5e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x004c130c -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x00d4b8cf -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x004bfd23 -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x004c1ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x00377628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
10 UIKit 0x00375134 -[UIViewController loadView] + 120
11 UIKit 0x0037500e -[UIViewController view] + 56
12 UIKit 0x00376a3d -[UIViewController viewControllerForRotation] + 63
13 UIKit 0x00372988 -[UIViewController _visibleView] + 90
14 UIKit 0x0061493c -[UIClientRotationContext initWithClient:toOrientation:duration:andWindow:] + 354
15 UIKit 0x002ec81e -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 954
16 UIKit 0x00574619 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 1381
17 UIKit 0x0037965d -[UIViewController presentModalViewController:withTransition:] + 3478
18 FunctionMachine 0x00001fdd -[FunctionMachineViewController startOnePlayer:] + 227
19 UIKit 0x002c54fd -[UIApplication sendAction:to:from:forEvent:] + 119
20 UIKit 0x00355799 -[UIControl sendAction:to:forEvent:] + 67
21 UIKit 0x00357c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
22 UIKit 0x00356a1c -[UIControl touchesBegan:withEvent:] + 277
23 UIKit 0x002e9d41 -[UIWindow _sendTouchesForEvent:] + 395
24 UIKit 0x002cac37 -[UIApplication sendEvent:] + 447
25 UIKit 0x002cff2e _UIApplicationHandleEvent + 7576
26 GraphicsServices 0x0172d992 PurpleEventCallback + 1550
27 CoreFoundation 0x00db6944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
28 CoreFoundation 0x00d16cf7 __CFRunLoopDoSource1 + 215
29 CoreFoundation 0x00d13f83 __CFRunLoopRun + 979
30 CoreFoundation 0x00d13840 CFRunLoopRunSpecific + 208
31 CoreFoundation 0x00d13761 CFRunLoopRunInMode + 97
32 GraphicsServices 0x0172c1c4 GSEventRunModal + 217
33 GraphicsServices 0x0172c289 GSEventRun + 115
34 UIKit 0x002d3c93 UIApplicationMain + 1160
35 FunctionMachine 0x00001c64 main + 102
36 FunctionMachine 0x00001bf5 start + 53
37 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Turns out that, when I went and changed the name of several UILabels in the header of GameViewController, I forgot to fix the names in the interface builder, too. Don't know if that was what was causing the debugger to act weird, but everything is working now!

I'm wondering how to add the #synthesize statements for the MovieEditorViewController header file in XCode

The implementation file looks like this:
#import "MovieViewController.h"
#import "Movie.h"
#import "MovieEditorViewController.h"
#implementation MovieViewController
#synthesize titleLabel;
#synthesize boxOfficeGrossLabel;
#synthesize summaryLabel;
#synthesize movie;
but i'm thinking my problem is not adding #synthesize statements for the MovieEditorViewController header file. If it's not this then I've included the debugging log below.
I'm really new to programming and I really can't seem to figure out whats going wrong. When I run the iOS simulator and click the button to display editable text fields the program terminates and goes back to the homescreen. The debugger shows as follows:
[Session started at 2011-06-04
13:00:00 +0100.] 2011-06-04
13:00:05.568 Movie[6678:207]
-[MovieViewController editingViewController]: unrecognized
selector sent to instance 0x8a3bd10
2011-06-04 13:00:05.572
Movie[6678:207] * Terminating app
due to uncaught exception
'NSInvalidArgumentException', reason:
'-[MovieViewController
editingViewController]: unrecognized
selector sent to instance 0x8a3bd10'
* Call stack at first throw: ( 0 CoreFoundation
0x00dc95a9 exceptionPreprocess + 185
1 libobjc.A.dylib
0x00f1d313 objc_exception_throw + 44
2 CoreFoundation
0x00dcb0bb -[NSObject(NSObject)
doesNotRecognizeSelector:] + 187 3
CoreFoundation
0x00d3a966 __forwarding + 966 4
CoreFoundation
0x00d3a522 _CF_forwarding_prep_0 + 50
5 Movie
0x000021b4 -[MovieViewController edit]
+ 62 6 UIKit 0x002b94fd -[UIApplication
sendAction:to:from:forEvent:] + 119 7
UIKit
0x00349799 -[UIControl
sendAction:to:forEvent:] + 67 8
UIKit
0x0034bc2b -[UIControl(Internal)
_sendActionsForEvents:withEvent:] + 527 9 UIKit
0x0034a7d8 -[UIControl
touchesEnded:withEvent:] + 458 10
UIKit
0x002ddded -[UIWindow
_sendTouchesForEvent:] + 567 11 UIKit
0x002bec37 -[UIApplication sendEvent:]
+ 447 12 UIKit 0x002c3f2e _UIApplicationHandleEvent +
7576 13 GraphicsServices
0x01721992 PurpleEventCallback + 1550
14 CoreFoundation
0x00daa944
CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION
+ 52 15 CoreFoundation 0x00d0acf7 __CFRunLoopDoSource1 + 215
16 CoreFoundation
0x00d07f83 __CFRunLoopRun + 979 17
CoreFoundation
0x00d07840 CFRunLoopRunSpecific + 208
18 CoreFoundation
0x00d07761 CFRunLoopRunInMode + 97 19
GraphicsServices
0x017201c4 GSEventRunModal + 217 20
GraphicsServices
0x01720289 GSEventRun + 115 21 UIKit
0x002c7c93 UIApplicationMain + 1160
22 Movie
0x00001b40 main + 102 23 Movie
0x00001ad1 start + 53 24 ???
0x00000001 0x0 + 1 ) terminate called
after throwing an instance of
'NSException'
If anyone could point me in the right direction i'd be very grateful...
Thanks!
Looks like you're in the iPhone SDK Development book. Have you made it to section 4.8 yet? The error says that your MovieViewController doesn't have a property named editingViewController, which is something you add in 4.8. The project won't build and run until you get through section 4.9, which is where you make some connections.

Object handling error in iPhone, select tab in UITabView and crash

Hey everyone, I'm creating a tab-view application, and in the one tab I have 7 textFields that I am trying to save the information for with a "Save" button. After making the connections between the objects in my controller.h file and the actual text fields, when I select the tab with all this stuff in it, the application crashes and goes to the springboard. I have the debug here:
2011-02-23 08:49:02.522 Tow Boat 911[19138:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4e0d1d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key colour.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00ec6be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00cbb5c2 objc_exception_throw + 47
2 CoreFoundation 0x00ec6b21 -[NSException raise] + 17
3 Foundation 0x000286cf _NSSetUsingKeyValueSetter + 135
4 Foundation 0x0002863d -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x004a78d6 -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x00e3d2cf -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x004a62ed -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x004a8081 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x00360a94 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
10 UIKit 0x0035e709 -[UIViewController loadView] + 120
11 UIKit 0x0035e5e3 -[UIViewController view] + 56
12 UIKit 0x00371230 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 120
13 UIKit 0x0036fd86 -[UITabBarController transitionFromViewController:toViewController:] + 64
14 UIKit 0x00371b7e -[UITabBarController _setSelectedViewController:] + 263
15 UIKit 0x003719ed -[UITabBarController _tabBarItemClicked:] + 352
16 UIKit 0x002b0a6e -[UIApplication sendAction:to:from:forEvent:] + 119
17 UIKit 0x004ae1f2 -[UITabBar _sendAction:withEvent:] + 422
18 UIKit 0x002b0a6e -[UIApplication sendAction:to:from:forEvent:] + 119
19 UIKit 0x0033f1b5 -[UIControl sendAction:to:forEvent:] + 67
20 UIKit 0x00341647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
21 UIKit 0x0033f16c -[UIControl sendActionsForControlEvents:] + 49
22 UIKit 0x002b0a6e -[UIApplication sendAction:to:from:forEvent:] + 119
23 UIKit 0x0033f1b5 -[UIControl sendAction:to:forEvent:] + 67
24 UIKit 0x00341647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
25 UIKit 0x003401f4 -[UIControl touchesEnded:withEvent:] + 458
26 UIKit 0x002d50d1 -[UIWindow _sendTouchesForEvent:] + 567
27 UIKit 0x002b637a -[UIApplication sendEvent:] + 447
28 UIKit 0x002bb732 _UIApplicationHandleEvent + 7576
29 GraphicsServices 0x016dda36 PurpleEventCallback + 1550
30 CoreFoundation 0x00ea8064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
31 CoreFoundation 0x00e086f7 __CFRunLoopDoSource1 + 215
32 CoreFoundation 0x00e05983 __CFRunLoopRun + 979
33 CoreFoundation 0x00e05240 CFRunLoopRunSpecific + 208
34 CoreFoundation 0x00e05161 CFRunLoopRunInMode + 97
35 GraphicsServices 0x016dc268 GSEventRunModal + 217
36 GraphicsServices 0x016dc32d GSEventRun + 115
37 UIKit 0x002bf42e UIApplicationMain + 1160
38 Tow Boat 911 0x00001df8 main + 102
39 Tow Boat 911 0x00001d89 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
Thanks everyone for any help in advance!
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key colour.
In this case check the following:
Ensure that you have not misspelled the key you are trying to access i.e. colour.
The class attribute you are trying to access i.e. colour should be Key Value compliant. You can have the attribute declared as a property in header and synthesize the same in the implementation file. Do not change the default name for the getter and setter in the property declaration. The default method name/signature is KVC compliant.
Apple documentation on KVC covering the accessor method code: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueCoding/Articles/Overview.html
If you are using core data ensure that the property being accessed is present in the corresponding header file and also has its code in the implementation file. It can happen that you have added this property later to the model and have not updated the generated header and implementation file.
Came across this post without an answer so thought I would put a response which may help someone else.