我很困惑。通常在iOS应用程序中,我将使用url方案访问设置。现在我发现使用Objective-C在MacOSX上你可以这样做:
NSDictionary *options = @{(id)kAXTrustedCheckOptionPrompt: @YES};
BOOL accessibilityEnabled = AXIsProcessTrustedWithOptions((CFDictionaryRef)options);
我已尝试将此转换为Swift但未获得有效结果。 有谁知道如何转换这个或一个有效的方法来请求Swift的辅助访问?
答案 0 :(得分:5)
kAXTrustedCheckOptionPrompt
类型为Unmanaged<CFString>
,因此您需要访问保留的值,如下所示
let options : NSDictionary = [kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString: true]
let accessibilityEnabled = AXIsProcessTrustedWithOptions(options)