SCNetworkCheckReachabilityByName will be deprecated anyways, so replace it with the docs example which will work on any OS version from 10.3.

Modified-by: Nathan Kinsinger <nkinsinger@brotherbard.com>
Released the target to stop memory leak.
This commit is contained in:
André Berg
2010-03-24 09:20:37 +01:00
committed by Nathan Kinsinger
parent d5f9c822af
commit fffa02425a
+8 -2
View File
@@ -110,8 +110,14 @@
- (BOOL) isReachable:(NSString *)hostname
{
SCNetworkConnectionFlags flags;
if (!SCNetworkCheckReachabilityByName([hostname cStringUsingEncoding:NSASCIIStringEncoding], &flags))
SCNetworkReachabilityRef target;
SCNetworkConnectionFlags flags = 0;
Boolean reachable;
target = SCNetworkReachabilityCreateWithName(NULL, [hostname cStringUsingEncoding:NSASCIIStringEncoding]);
reachable = SCNetworkReachabilityGetFlags(target, &flags);
CFRelease(target);
if (!reachable)
return FALSE;
// If a connection is required, then it's not reachable