Exception: terminate called throwing an exceptionsharedlibrary apply-load-rules all - ios

I am trying to pull a VC xib, by adding the view of controller on window's view. When I execute the program nothing appears (a black screen), and expectation was a button put on view of VC in xib.
But when I declare that this VC is my Project's main interface (Project Summary), then it throws the exception : terminate called throwing an exceptionsharedlibrary apply-load-rules all and application crashes.
Here is the code for didfinishlaunch (Appdelegate)
[self.window addSubview:rootViewController.view];
[self.window makeKeyAndVisible];
Can somebody assist on that.
Thanks
PS: the complete error is given below
2012-02-26 11:50:08.003 PasswordGeneratorTest[1161:f803] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
* First throw call stack:
(0x13b9052 0x154ad0a 0x13b8f11 0x9b0032 0x921f7b 0x921eeb 0x93cd60 0x22f91a 0x13bae1a 0x1324821 0x22e46e 0x230010 0x1014a 0x10461 0xf7c0 0x1e743 0x1f1f8 0x12aa9 0x12a3fa9 0x138d1c5 0x12f2022 0x12f090a 0x12efdb4 0x12efccb 0xf2a7 0x10a9b 0x1d42 0x1cb5)
terminate called throwing an exceptionsharedlibrary apply-load-rules all
Current language: auto; currently objective-c
Single stepping until exit from function __pthread_kill,
which has no line number information.

I can't see your stack trace code or the message the debugger is giving you, but there's ALWAYS 2 reasons why it would crash here:
rootViewController.view is nil or doesn't have its view outlet set in IB.
self.window is not set in code or doesn't have its outlet connected in IB.
Check all of your outlets and see if it fixes it.

Related

How do I find which button the console is referring to in Xcode?

I'm getting a runtime error:
Failed to set (keyPath) user defined inspected property on (UIButton): [<UIButton 0x13fe79390> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key keyPath.
Since I have thousands of UIButtons, is there a quick way to find what does this number 0x13fe79390 correspond to? I know I can po 0x13fe79390 but that doesn't do anything.
This solution is for debugging forUndefinedKey. First try to add an All exception breakpoint. The compiler will stop at where the error happens.
Also, you can add a symbolic breakpoint,like the screenshot I post,then right click the breakpoint,selected edit breakpoint
Then it will stop at setValue:forUndefinedKey:. You can see the call tree from the screenshot of the left part. Here my error happens at [ViewController viewDidLoad]
Also, you can use the address in LLDB. This is how you instantiate a button object
e UIButton * $b = (UIButton*)0x7fb938c64750
This is how you print a button's superView information:
po [$b superview]

performSegueWithIdentifier: causes app to crash

I have a button that is pressed after user enters email information. I have an alert view that is displayed when there is no email entered but if there is I want the button to segue to another view controller.
The following code causes my app to crash. I have no idea why. Please help.
(note: I have tried "sender:self]" "sender:nil]" and "sender:sender]" and they all make my app crash.)
- (IBAction)nextButtonPushed:(id)sender {
if ([self.emailTextField.text isEqual: #""]) {
emailAlertView = [[UIAlertView alloc] initWithTitle:#"Missing Email" message:#"A destination email is required to send." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[emailAlertView show];
self.nextButton.enabled = NO;
}
else {
eString = self.eTextField.text;
hString = self.hField.text;
emailAddress = self.emailTextField.text;
[userDefaults setObject:eString forKey:#"e"];
[userDefaults setObject:hString forKey:#"h"];
[userDefaults setObject:emailAddress forKey:#"email"];
[self performSegueWithIdentifier:#"next" sender:self];
}
}
There are three overwhelmingly likely possibilities:
Perhaps the storyboard really has no segue named "next" emerging from the FirstViewController scene. Be careful: spaces and capitalization and things like that matter.
Perhaps the storyboard has a segue named "next" but it emerges from a different scene (a different view controller).
Perhaps the FirstViewController instance represented by self in your code is not the same as the FirstViewController instance in the storyboard, i.e. maybe it came into existence in some other way and not by instantiation from the storyboard. You might even have two FirstViewController objects in the storyboard, and the segue comes from the other one.
One great way to figure out why your app is crashing on a line like this is to disable any breakpoints you may have (including exception breakpoints). This will cause the app to crash and often tell you a reason why it is crashing. Normally you'll get error's like #matt mentioned such as bad identifiers on your seques (often typing errors), multiple of the same object in an IB scene such as the following:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<YOURAPP.YOURVIEWCONTROLLER: 0x7c8951d0>) has no segue with identifier 'TheSequeIdentifierYouHaventSetYetOrTypedInWrong''
or like in my case today where I got this error:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<YOURAPP.YOURVIEWCONTROLLERYOUARETRYINGTOSHOW 0x78e5a140> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key "MyKeyOnTheOffendingObject"
Once I knew that I had an object in my storyboard with a key that it should not have all I had to do was track down the Button/Image/Other Random Object with the bad Referencing Outlet or Sent Event and all was fixed
Often performSequeWithIdentifier will come up as the last line shown before a crash since that is the last line that worked before a problem was found when presenting a new View Controller - so if you are sure the problem isn't with your seque then check references on the VC you are trying to present!
Crashing can also occur if the view controller cannot load from the NIB. For example if there is an incorrectly named User Defined Runtime Attribute.
For example QBFlatButton changed their API today and my app started crashing. This is why we use semantic versioning :-)

Getting 'NSUnknownKeyException' after deleting a control and the corresponding outlet in the code

I am writing a very simple app with just one view controller. However I am getting an exception:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key
Here is what I did:
added a UIImageView and created an outlet in the code by ctrl-dragging to the assistant editor.
deleted the UIImageView cause I don't need
deleted the outlet property from the code
checked the connection inspector and removed the outlet from the storyboard/InterfaceBuilder.
But I am still getting the exception as listed above, could anyone give me some hints?
Usually you should do a clean of your project, found in the Project menu next to build That way xib files get recreated and often such errors disappear.

Error when moving view Controller

I get an error saying
*** Assertion failure in -[HatsViewController loadView], /SourceCache/UIKit/UIKit-2380.17/UICollectionViewController.m:104
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UICollectionViewController loadView] loaded the "FCD-ki-UFO-view-1vb-8P-s3C" nib but didn't get a UICollectionView.'
*** First throw call stack:
(0x3467c2a3 0x3c36097f 0x3467c15d 0x34f51ab7 0x368aaa95 0x364a346d 0x3652f353 0x36570d11 0x3656ffe7 0x366923ef 0x3656f0c5 0x3656f077 0x3656f055 0x3656e90b 0x3656ee01 0x364975f1 0x36484801 0x3648411b 0x3818b5a3 0x3818b1d3 0x34651173 0x34651117 0x3464ff99 0x345c2ebd 0x345c2d49 0x3818a2eb 0x364d8301 0xc0dfd 0x3c797b20)
libc++abi.dylib: terminate called throwing an exception
(lldb)
Why does this happen and how can I fix it?
When you’re using a UICollectionViewController, the view outlet needs to be connected to a UICollectionView in your storyboard; if it’s a UIView of another class, it’ll crash.
check HatsViewController.h is inherited from UICollectionViewController but you have connected it view in your storyboard. Either it must be subclass of UIViewController or it is connected to UICollectionView in your storyboard.

How to fix error [<UIViewController 0x752f5a0> setValue:forUndefinedKey:]

I'm new to IOS and I'm stuck with an error I added a table view in my storyboard named timelinetable and after some time I deleted that from my storyboard but after that when debugging it shows an error
Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[ setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key
timelineTable.'
but I cant find anything named timelinetable in my project so how can I fix that problem
Go to the xib
click on files owner and click on the show connection inspector button (last one ).
Check out all the connections . The problem is due to you are referencing the outlet which is no more exist.
you connect an outlet and you then remove the controller without removing its outlet.

Resources