How do I call the following function:
func AXUIElementCopyAttributeNames(element: AXUIElement!, names: UnsafePointer
I am a little bit guessing (because I have no experience with the Accessibility functions), but from the function declaration it should work like this:
let element: AXUIElementRef = ...
var ptr : Unmanaged? = nil
let error = AXUIElementCopyAttributeNames(element, &ptr)
if error == AXError(kAXErrorSuccess) {
let names = ptr!.takeRetainedValue() // gives a CFArray
// ...
}
Update for Swift 3 (untested):
let element: AXUIElement = ...
var cfArray: CFArray?
let error = AXUIElementCopyAttributeNames(element, &cfArray)
if error == .success, let names = cfArray as? [String] {
// names is [String] array ...
}