views:

65

answers:

1

I simply need to have a notification post when a valid IP address is assigned. I have tried polling via SCReachability, but that seems to be inefficient.

Any suggestions? This seems like it should be simple, but I've been struggling for several hours to get anything working.

A: 

You don't have to poll with SCNetworkReachability. You register the callback, and the system calls the callback when the network state changes. It's not inefficient.

See Apple's sample code Reachability which shows how to integrate it into an Objective-C app. The code is for iPhone, but I think Reachability.{m,h} should work on OS X.

(See Apple's sample code SimpleReach. It's five years old, but should work.)

Yuji
I have to admit - I'm exceptionally confused at this example. I am very new to Cocoa, and I not sure I understand how to integrate this C example into my ObjC program. Hints?
Andrew J. Freyer
Found a newer sample code at Apple. See the new answer.
Yuji