2009-05-06 47 views
1

在BubbleLevel例如從蘋果的AppDelegate他們做這樣的事情:爲什麼要在初始化方法中檢查[self class] == [LevelAppDelegate類]?

+ (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類]

回答

相關問題