Read iPhone Settings Programmatically (Precisely S

2019-02-06 20:25发布

问题:

We are developing an iPhone application for which i need to read iPhone Settings value (precisely the status of 'Settings->General->Date & Time->Set Automatically'). Is there any way easy/difficult way to find out that value? Any tips and tricks will be highly appreciated.

回答1:

You can use the following code (I just found this out by examining the contents of the /var/mobile/Library/Preferences/ directory on my iPad):

NSDictionary *pref = [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.apple.timed"];
BOOL autotime = [[pref objectForKey:@"TMAutomaticTimeEnabled"] boolValue];
NSLog(@"Automatic time is %@", autotime ? @"enabled" : @"disabled");

These keys are undocumented and you should probably not use them in an AppStore app. You can, however, safely use them in in-house apps or softwares for jailbroken devices.



回答2:

Nope, sorry, this is not possible.