开发者

Getting NSUnknownKeyException when running app under Instruments

开发者 https://www.devze.com 2023-04-04 11:47 出处:网络
I\'m trying to scan my application (window based with xib) for memory leaks, but when I\'m running the app with Leaks tool, it crashes with exception

I'm trying to scan my application (window based with xib) for memory leaks, but when I'm running the app with Leaks tool, it crashes with exception

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIWindow 0x4d20ec0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key rootViewController.'

It's strange, the app runs well in simulator and on device.

App delegate code:

#import "myAppDelegate.h"

@implementation myAppAppDelegate

@synthesize window;
@synthesize myController;


#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplica开发者_JAVA百科tion *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    NSLog(@"didFinishLaunchingWithOptions");

    [window addSubview:myController.view];
    [window makeKeyAndVisible];

    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
}

- (void)applicationWillTerminate:(UIApplication *)application {
=}

#pragma mark -
#pragma mark Memory management

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
}


- (void)dealloc {
    [window release];
    [super dealloc];
}

@end


This error usually occurs when there's a property in Interface Builder that is not set correctly, or does not exist anymore (look for warnings in Interface Builder).

As to why it's crashing only in Instruments may be because it defaults to run against your release build, and there may be some optimizations that are less forgiving for faulty configurations.


Does this work in the normal simulator, or on device without issues?

Otherwise did you implement a custom root view, ie using a different launch NIB?

it would be best if you upload your app delegate code

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号