質問

My app developed in Xcode 4.5 on Mountain Lion runs flawlessly on Lion and ML.

My Snow Leopard tester reports that when the app starts, it is disabled. By that he means none of the controls are active and the red, yellow, green 'traffic light' is greyed out. If another app is opened that covers my app, when the covering app is moved, any control, or part of a control it covered is not there.

The menu bar is responsive, and my preferences panel works. The app can be shut down from the menu, I don't know if it can be shut from the keyboard.

Another app that uses the same serial code works fine.

I need help with putting together a plan to solve it. I don't know how to trace this.

役に立ちましたか?

解決

Fundamentally, the problem is that you're expecting data to be in NSUserDefaults. On first launch, NSUserDefaults returns nil for the keys you access, and passing this nil result through later code causes exceptions to be thrown. The solution is to register defaults with NSUserDefaults upon application startup:

@implementation AppController
+ (void)initialize
{
    NSDictionary *defaultValues = @{@"SomeKey" : @"DefaultValue"};
    [[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues];
}
@end
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top