有没有人知道在10.12.4 beta中控制夜班的终端命令?我一直在查看plist文件,但找不到与夜班有关的任何内容.
我正在寻找一种方法来确定何时启用或禁用夜班,并基于此执行操作.我目前正在使用CoreBrightness框架中的CBBlueLightClient标头来控制夜班.这是我在我的应用中使用的部分标题:
@interface CBBlueLightClient : NSObject
- (BOOL)setStrength:(float)strength commit:(BOOL)commit;
- (BOOL)setEnabled:(BOOL)enabled;
- (BOOL)getStrength:(float*)strength;
- (BOOL)getBlueLightStatus:(struct { BOOL x1; BOOL x2; BOOL x3; int x4; struct { struct { int x_1_2_1; int x_1_2_2; } x_5_1_1; struct {
int x_2_2_1; int x_2_2_2; } x_5_1_2; } x5; unsigned long x6; }*)arg1;
@end
Run Code Online (Sandbox Code Playgroud)
CBBlueLightClient也有一个通知块,-
(void)setStatusNotificationBlock:(id /* block */)arg1;我无法弄清楚如何使用.
这是iOS的完整标题.我尝试过的所有内容都适用于macOS,包括似乎存在的通知块.我只是无法弄清楚它期待什么样的闭合.
我正在尝试设置当我的应用程序请求位置授权时显示的字符串。我尝试在 Info.plist 中设置所有四个可能的键:
NSLocationUsageDescription
NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription
Run Code Online (Sandbox Code Playgroud)
我还尝试设置在 iOS 中不推荐使用的locationManager.purpose字符串,但在 macOS 中不推荐使用。当应用程序请求授权时,这些方法都不会导致该字符串出现在警报中。
我正在使用此代码来请求访问权限:
var locationManager = CLLocationManager()
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
switch status {
case .notDetermined:
locationManager.startUpdatingLocation()
locationManager.stopUpdatingLocation()
default: break
}
}
Run Code Online (Sandbox Code Playgroud)
这是警报的屏幕截图:
Calendar.app 能够自定义警报:
在我的菜单栏应用程序中,我有一个可打开窗口的菜单项。窗户在前面打开,后面的窗户仍然是关键窗户。
window.makeKey()除非在断点后运行它,否则我无法开始工作。我尝试将这行代码放在窗口生命周期的不同位置,甚至放入DispatchQueue.main.asyncAfter(deadline: execute:)也不起作用。
我也尝试过使用window.makeKeyAndOrderFront(sender:). 楼盘window.canBecomeKey属实。
macos ×4
beta ×1
info.plist ×1
ios ×1
macos-sierra ×1
night-shift ×1
nswindow ×1
swift ×1
terminal ×1