• 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: Cocoa Selector As CF Callback Addr?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa Selector As CF Callback Addr?


  • Subject: Re: Cocoa Selector As CF Callback Addr?
  • From: Sherm Pendley <email@hidden>
  • Date: Fri, 19 Nov 2004 06:04:41 -0500


On Nov 19, 2004, at 5:42 AM, Lance Drake wrote:

There's a great new API demonstrated in the demo 'SimpleReach' project.
In it, there's a local routine that gets notified when net connectivity
changes. The routine in the sample code looks like this in the code:

Boolean ok = SCNetworkReachabilitySetCallback(	thisTarget,
                                              MyReachabilityCallback,
                                              &thisContext );

The callback function you need to give here must be exactly that - a *function*, not a method or a selector. As is typical with many C callbacks however, the context parameter is simply passed to your callback function as-is. It's there solely for your own use. So what you do is pass an object as the context argument, and then within your callback function reflect the call to that object.


When you set the callback:

Boolean ok = SCNetworkReachabilitySetCallback(
        thisTarget,
        MyReachabilityCallback,
        (void *)self
    );

Your callback function:

static void MyReachabilityCallback(
SCNetworkreachabilityRef target,
SCNetworkConnectionFlags flags,
void *info)
{
[(MyClass *)info reachabilityCallbackTarget:target withFlags:flags];
}


sherm--

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Cocoa Selector As CF Callback Addr? (From: Lance Drake <email@hidden>)

  • Prev by Date: Cocoa Selector As CF Callback Addr?
  • Next by Date: Re: NSPanel with just a close button & title on title bar?
  • Previous by thread: Cocoa Selector As CF Callback Addr?
  • Next by thread: Re: Cocoa Selector As CF Callback Addr?
  • Index(es):
    • Date
    • Thread