开发者

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

开发者 https://www.devze.com 2023-03-21 03:11 出处:网络
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

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

精彩评论

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