• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: RunLoop and callback function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: [APP IDEA] Desktop Background Scripting
  • Next by Date: Launch an application with a specific language
  • Previous by thread: Re: RunLoop and callback function
  • Next by thread: windowDidBecomeMain when app being made active
  • Index(es):
    • Date
    • Thread