• 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
Using SCNetworkReachability callbacks in Objective-C app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using SCNetworkReachability callbacks in Objective-C app


  • Subject: Using SCNetworkReachability callbacks in Objective-C app
  • From: Paul Borokhov <email@hidden>
  • Date: Wed, 26 Dec 2007 00:25:37 -0800

Hope someone here will be able to help me out...
I have a regular Objective-C/Cocoa app. In my main Controller class, I have instance variables
	Boolean isReachable;
	SCNetworkReachabilityRef facebookName;

In my application initialization code I have
	facebookName = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [@"www.facebook.com" cStringUsingEncoding:NSISOLatin1StringEncoding]);

	if (SCNetworkReachabilitySetCallback(facebookName, networkStatusDidChange, NULL) &&
		SCNetworkReachabilityScheduleWithRunLoop(facebookName, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) {
		CFRunLoopRun();
	}

Then, here's the callback function:
  void networkStatusDidChange(SCNetworkReachabilityRef name, SCNetworkConnectionFlags flags, void * infoDictionary) {
	if (name != NULL) {
		if (flags != kSCNetworkFlagsReachable) {
			isReachable = NO;
		} else {
			isReachable = YES;
		}
	}
  }
However, this code won't work due to a compile-time error at the lines where I try to set isReachable: error: 'isReachable' was not declared in this scope.
What am I doing wrong here?
Thanks and happy holidays!
Paul
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: NSHTTPCookieStorage notification troubles
  • Next by Date: How can know a file is hidden?
  • Previous by thread: Re: WebView and Rtf
  • Next by thread: Re: Using SCNetworkReachability callbacks in Objective-C app
  • Index(es):
    • Date
    • Thread