Is there a library or a tool to check if user cho开发者_StackOverflow中文版ose "Require password after sleep"? Thanks in advance! Example code will be very much appreciated.
It's in the screensaver preferences. If you do this you'll see it:
defaults read com.apple.screensaver askForPassword
You can use the NSUserDefaults APIs to read this programmatically from Cocoa like this:
NSDictionary *prefs=[[NSUserDefaults standardUserDefaults]
persistentDomainForName:@"com.apple.screensaver"];
BOOL isSet = [[prefs objectForKey:@"askForPassword"] boolValue];
精彩评论