views:

19

answers:

1

I am using an AXObserver to monitor when a window is closed. In the callback, I am just raising an NSNotification. All working well.

What is the correct syntax for attaching some user data as refcon? The working call looks like this:

err6 = AXObserverAddNotification(observerTable, tableRef, kAXUIElementDestroyedNotification, nil);

and the callback specified when I create the observer has the signature:

static void cbTableClosed (AXObserverRef observer, AXUIElementRef element, CFStringRef notification, void *refcon)

I want to replace refcon with an object of my own, but don't know how to change either line. The obvious objective-c type changes through up warnings.

A: 

Cast the object's id to void * when adding the observer, and cast back to the specific object type (MyObject *) within the cbTableClosed function body.

Peter Hosey