Reputation: 643
I'm pretty confused. Usually in an iOS app I would access the settings using a url scheme. Now I found out that on MacOSX using Objective-C you can do this:
NSDictionary *options = @{(id)kAXTrustedCheckOptionPrompt: @YES};
BOOL accessibilityEnabled = AXIsProcessTrustedWithOptions((CFDictionaryRef)options);
I've tried to convert this to Swift but didn't got to a valid result. Does anyone know how to convert this or a valid method to ask for assistive access in Swift?
Upvotes: 8
Views: 3046
Reputation: 3532
The kAXTrustedCheckOptionPrompt
type is Unmanaged<CFString>
so you need to access to the retained value as show below
let options : NSDictionary = [kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString: true]
let accessibilityEnabled = AXIsProcessTrustedWithOptions(options)
Upvotes: 13