我的问题与我用来检测格式更改的特定通知有关。
当AppleDatePreferencesChangedNotification
交付,该区域还没有更新,所以无论是我的尝试,可可正在更新使用旧的语言环境信息领域。在短暂的延迟后,语言环境更新,一切正常。
我想这就是为什么NSCurrentLocaleDidChangeNotification
10.5加入,但因为我支持回到10.4,我会使用此解决办法现在。
NSDistributedNotificationCenter *distributedNotificationCenter = [NSDistributedNotificationCenter defaultCenter];
[distributedNotificationCenter addObserver: self selector: @selector(_dateFormatsChanged:) name: @"AppleDatePreferencesChangedNotification" object: nil];
// ...
- (void)_localeChanged;
{
// ... update stuff ...
}
- (void)_dateFormatsChanged:(NSNotification *)notification;
{
// XXX delay while NSLocale updates - can we use another notification instead?
// XXX 10.5+ has NSCurrentLocaleDidChangeNotification
[self performSelector: @selector(_localeChanged) withObject: nil afterDelay: 0.1];
}
是否有任何格式化程序使用了两个字段,其中一个已启用,另一个不是?如果是这样,那么每个领域会发生什么? –
不,每个格式化程序都由单个字段使用。如果你想玩它 - http://sabi.net/temp/PesterSL.zip(来源http://github.com/nriley/Pester) - 我在谈论的领域是“在”和“上”。 –