Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RunLoop and callback function



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.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.