开发者

Is there a way to programmatically check that user choose "Require password after sleep" on Mac?

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜