开发者

Attaching user data to AXObserver

开发者 https://www.devze.com 2022-12-29 05:06 出处:网络
I am using an AXObserver to开发者_开发百科 monitor when a window is closed.In the callback, I am just raising an NSNotification.All working well.

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消