Re: RunLoop and callback function
Re: RunLoop and callback function
- Subject: Re: RunLoop and callback function
- From: Eric Forget <email@hidden>
- Date: Tue, 27 Jan 2004 15:07:06 -0500
Hi Thierry,
Hmmm. You are trying to mismatch C callback with Objective-C message. You
cannot do this. This is the same thing with C++: you cannot use member
function as callback. So code the below is the way it should work:
void PowerSourcesHaveChanged(void *info)
{
NSLog(@"ca a changi...");
[(YourClassName *)info doThisPlease];
}
-(void)initializePowerSourceChanges
{
CFRunLoopSourceRef CFrls;
// Create and add RunLoopSource
// Here I pass my context instead of NULL!
CFrls =
IOPSNotificationCreateRunLoopSource(PowerSourcesHaveChanged, self);
if(CFrls) {
CFRunLoopAddSource(CFRunLoopGetCurrent(), CFrls,
kCFRunLoopDefaultMode);
CFRelease(CFrls);
}
}
Eric
___________________________________________________________________
Eric Forget Cafederic
email@hidden <
http://www.cafederic.com/>
Fingerprint <86D5 38F5 E1FD 5D9C 71C3 BAA3 797E 70A4 6210 C684>
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.