diff --git a/Reachability.m b/Reachability.m index 4c1c94a..e834438 100644 --- a/Reachability.m +++ b/Reachability.m @@ -40,7 +40,7 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF @interface Reachability () -@property (nonatomic, assign) SCNetworkReachabilityRef reachabilityRef; +@property (nonatomic, strong) __attribute__((NSObject)) SCNetworkReachabilityRef reachabilityRef; @property (nonatomic, strong) dispatch_queue_t reachabilitySerialQueue; @property (nonatomic, strong) id reachabilityObject; @@ -99,6 +99,7 @@ +(instancetype)reachabilityWithHostname:(NSString*)hostname if (ref) { id reachability = [[self alloc] initWithReachabilityRef:ref]; + CFRelease(ref); return reachability; } @@ -112,6 +113,7 @@ +(instancetype)reachabilityWithAddress:(void *)hostAddress if (ref) { id reachability = [[self alloc] initWithReachabilityRef:ref]; + CFRelease(ref); return reachability; } @@ -165,12 +167,7 @@ -(void)dealloc { [self stopNotifier]; - if(self.reachabilityRef) - { - CFRelease(self.reachabilityRef); - self.reachabilityRef = nil; - } - + self.reachabilityRef = nil; self.reachableBlock = nil; self.unreachableBlock = nil; self.reachabilityBlock = nil;