在 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];
}
}
他们为什么这样做 [self class] == [LevelAppDelegate class] ?