Permalink
Browse files

Use SCNetworkReachabilityCreateWithName rather than SCNetworkCheckRea…

…chabilityByName, which is deprecated.
  • Loading branch information...
1 parent e71915b commit 9cc1905f87bc26d1ebc8102ef1e14256569fe3b2 @ksuther ksuther committed Jul 25, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 SUUpdater.m
View
10 SUUpdater.m
@@ -17,7 +17,7 @@
#import "SUScheduledUpdateDriver.h"
#import "SUConstants.h"
#import "SULog.h"
-#include <SystemConfiguration/SCNetwork.h> // UK 2007-04-27
+#include <SystemConfiguration/SystemConfiguration.h>
@interface SUUpdater (Private)
@@ -232,7 +232,13 @@ -(void) checkForUpdatesInBgReachabilityCheckWithDriver: (SUUpdateDriver*)inDrive
// Don't perform automatic checks on unconnected laptops or dial-up connections that aren't online:
NSMutableDictionary* theDict = [NSMutableDictionary dictionary];
[self performSelectorOnMainThread: @selector(putFeedURLIntoDictionary:) withObject: theDict waitUntilDone: YES]; // Get feed URL on main thread, it's not safe to call elsewhere.
- if( SCNetworkCheckReachabilityByName( [[[theDict objectForKey: @"feedURL"] host] cStringUsingEncoding: NSUTF8StringEncoding], &flags ) )
+
+ const char *hostname = [[[theDict objectForKey: @"feedURL"] host] cStringUsingEncoding: NSUTF8StringEncoding];
+ SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, hostname);
+ Boolean reachabilityResult = SCNetworkReachabilityGetFlags(reachability, &flags);
+ CFRelease(reachability);
+
+ if( reachabilityResult )
{
BOOL reachable = (flags & kSCNetworkFlagsReachable) == kSCNetworkFlagsReachable;
BOOL automatic = (flags & kSCNetworkFlagsConnectionAutomatic) == kSCNetworkFlagsConnectionAutomatic;

0 comments on commit 9cc1905

Please sign in to comment.