Skip to content

Commit

Permalink
Use SCNetworkReachabilityCreateWithName rather than SCNetworkCheckRea…
Browse files Browse the repository at this point in the history
…chabilityByName, which is deprecated.
  • Loading branch information
ksuther committed Jul 25, 2011
1 parent e71915b commit 9cc1905
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions SUUpdater.m
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9cc1905

Please sign in to comment.