My application was running fine until today it started to crash at: [self.window makeKeyAndVisible]; in app delegate.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[ViewControllerWordHelper alloc] initWithNibName:@"ViewControllerWordHelper_iPhone1" bundle:nil];
} else {
self.viewController = [[ViewControllerWordHelper alloc] initWithNibName:@"ViewControllerWordHelper_iPhone" bundle:nil];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
If I debug and step inside at [self.window makeKeyAndVisible], the next statement before crashing is "@synthesize window = _window;" in the same app delegate.
All the previous versions that used to work behave the same.
I restarted my computer and still the same is happening. I am using XCode 4.2. Is there anything in xcode setup that I may have accidentally changed?
Thanks for any help.
The following is the whole debug window:
`GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 15 16:03:10 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 440.
Pending breakpoint 3 - ""ViewControllerWordHelper.m":136" resolved
Pending breakpoint 4 - ""AppDelegate.m":41" resolved
Pending breakpoint 5 - ""ViewControllerWordHelper.m":27" resolved
Pending breakpoint 6 - ""ViewControllerWordHelper.m":166" resolved
Current language: auto; currently objective-c
(gdb) `
Another big cause of this is if you connected an object to something in a .xib and then deleted the object because you decided you didn't need it but forgot to destroy the connection.
If you've created the project for iOS 6 and then you changed the deployment target to 5.1, it's the Autolayout from the .xibs.
Open each .xib, click on 'Show Utilities' button (3rd from the view group), then go to 'Show File Inspector' (first tab), tick off 'Use Autolayout' and change Deployment to 5.1. (see attached screenshot).
This crash happened to me when I removed some IBOutlet properties that were linked up to my XIB.
If you get an error like this:
2012-09-20 09:45:07.920 AppName[78792:c07] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0xa2b3000> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key
NonexistentPropertyNameHere.'
Find that referencing outlet in your XIB and remove it or re-add that property to your view controller.
Maybe someone else can benefit from this. I've gotten this crash at makeKeyAndVisible and tried everything suggested here and anywhere else I could find. No success. Still crashes.
I did comment out the line that makeKeyAndVisible is on, but then the ViewController never loads.
Just to see what would happen, I split makeKeyAndVisible in two:
[self.window makeKeyWindow];
self.window.hidden = NO;
It crashes at the second line, so apparently iOS doesn't like the hidden key.
From the debugging console:
0 CoreFoundation 0x0173b5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014be8b6 objc_exception_throw + 44
2 CoreFoundation 0x017cb6a1 -[NSException raise] + 17
3 Foundation 0x0117f9ee -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4 Foundation 0x010ebcfb _NSSetUsingKeyValueSetter + 88
5 Foundation 0x010eb253 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6 Foundation 0x0114d70a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
My expertise is in assembly language programming and Objective-C is pretty mysterious to me, so I don't know where to go from here.
More information: I moved this instruction down to just before the return at the end of application didFinishLaunching... and now it is crashing on this:
self.window.rootViewController = self.viewController;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With