5
我试图获取com.apple.scheduler plist中的repeatInterval键的值。我想只要使用的NSDictionary的valueForKeyPath:方法如下所示:是否有可能调用NSDictionary的valueForKeyPath:当一个键包含句点?
CFPropertyListRef value;
value = CFPreferencesCopyValue(CFSTR("AbsoluteSchedule"),
CFSTR("com.apple.scheduler"),
kCFPreferencesCurrentUser,
kCFPreferencesCurrentHost);
NSNumber *repeatInterval = [(NSDictionary *)value valueForKeyPath:@"com.apple.SoftwareUpdate.SUCheckSchedulerTag.Timer.repeatInterval"];
但这样做的问题是,第一个关键是真正的“com.apple.SoftwareUpdate”,不只是“COM”。我可以分别获得该第一个值解决这个问题:
NSDictionary *dict = [(NSDictionary *)value valueForKey:@"com.apple.SoftwareUpdate"];
NSNumber *repeatInterval = [dict valueForKeyPath:@"SUCheckSchedulerTag.Timer.repeatInterval"];
我只是想知道是否有逃脱的时期的keyPath这样我就可以消除这种额外的步骤的方法。
我不认为我经常会遇到这个问题,以至于无法为其编写一个类别,所以我现在只是坚持使用额外的代码。感谢您的澄清。 – Jonukas 2010-05-15 03:14:05