我为什么要在initialize方法中检查[self class] == [LevelAppDelegate class]?

时间:2009-05-06 09:20:59

标签: iphone cocoa-touch uikit

在Apple的BubbleLevel示例的AppDelegate中,他们执行以下操作:

+ (void)initialize {
    if ([self class] == [LevelAppDelegate class]) {
        // Register a default value for the instrument calibration. 
        // This will be used if the user hasn't calibrated the instrument.
        NSNumber *defaultCalibrationOffset = [NSNumber numberWithFloat:0.0];
        NSDictionary *resourceDict = [NSDictionary dictionaryWithObject:defaultCalibrationOffset forKey:BubbleLevelCalibrationOffsetKey];
        [[NSUserDefaults standardUserDefaults] registerDefaults:resourceDict];
    }
}

为什么他们这样做[自我类] == [LevelAppDelegate类]?

1 个答案:

答案 0 :(得分:3)