diff --git a/Reachability.m b/Reachability.m index 4c1c94a..46d027b 100644 --- a/Reachability.m +++ b/Reachability.m @@ -98,8 +98,9 @@ +(instancetype)reachabilityWithHostname:(NSString*)hostname SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithName(NULL, [hostname UTF8String]); if (ref) { - id reachability = [[self alloc] initWithReachabilityRef:ref]; - + id reachability = [[self alloc] initWithReachabilityRef:CFBridgingRetain((__bridge id)ref)]; + CFRelease(ref); + return reachability; } @@ -111,7 +112,8 @@ +(instancetype)reachabilityWithAddress:(void *)hostAddress SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress); if (ref) { - id reachability = [[self alloc] initWithReachabilityRef:ref]; + id reachability = [[self alloc] initWithReachabilityRef:CFBridgingRetain((__bridge id)ref)]; + CFRelease(ref); return reachability; }