Skip to content

Commit

Permalink
Merge pull request tonymillion#84 from PatrickNLT/master
Browse files Browse the repository at this point in the history
Use instancetype keyword to allow subclassing
  • Loading branch information
tonymillion committed Dec 19, 2014
2 parents 402b766 + a911c2f commit 472b00e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions Reachability.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ typedef void (^NetworkUnreachable)(Reachability * reachability);
@property (nonatomic, assign) BOOL reachableOnWWAN;


+(Reachability*)reachabilityWithHostname:(NSString*)hostname;
+(instancetype)reachabilityWithHostname:(NSString*)hostname;
// This is identical to the function above, but is here to maintain
//compatibility with Apples original code. (see .m)
+(Reachability*)reachabilityWithHostName:(NSString*)hostname;
+(Reachability*)reachabilityForInternetConnection;
+(Reachability*)reachabilityWithAddress:(void *)hostAddress;
+(Reachability*)reachabilityForLocalWiFi;
+(instancetype)reachabilityWithHostName:(NSString*)hostname;
+(instancetype)reachabilityForInternetConnection;
+(instancetype)reachabilityWithAddress:(void *)hostAddress;
+(instancetype)reachabilityForLocalWiFi;

-(Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;
-(instancetype)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;

-(BOOL)startNotifier;
-(void)stopNotifier;
Expand Down
14 changes: 7 additions & 7 deletions Reachability.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ @implementation Reachability

#pragma mark - Class Constructor Methods

+(Reachability*)reachabilityWithHostName:(NSString*)hostname
+(instancetype)reachabilityWithHostName:(NSString*)hostname
{
return [Reachability reachabilityWithHostname:hostname];
}

+(Reachability*)reachabilityWithHostname:(NSString*)hostname
+(instancetype)reachabilityWithHostname:(NSString*)hostname
{
SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithName(NULL, [hostname UTF8String]);
if (ref)
Expand All @@ -106,7 +106,7 @@ +(Reachability*)reachabilityWithHostname:(NSString*)hostname
return nil;
}

+(Reachability *)reachabilityWithAddress:(void *)hostAddress
+(instancetype)reachabilityWithAddress:(void *)hostAddress
{
SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);
if (ref)
Expand All @@ -119,8 +119,8 @@ +(Reachability *)reachabilityWithAddress:(void *)hostAddress
return nil;
}

+(Reachability *)reachabilityForInternetConnection
{
+(instancetype)reachabilityForInternetConnection
{
struct sockaddr_in zeroAddress;
bzero(&zeroAddress, sizeof(zeroAddress));
zeroAddress.sin_len = sizeof(zeroAddress);
Expand All @@ -129,7 +129,7 @@ +(Reachability *)reachabilityForInternetConnection
return [self reachabilityWithAddress:&zeroAddress];
}

+(Reachability*)reachabilityForLocalWiFi
+(instancetype)reachabilityForLocalWiFi
{
struct sockaddr_in localWifiAddress;
bzero(&localWifiAddress, sizeof(localWifiAddress));
Expand All @@ -144,7 +144,7 @@ +(Reachability*)reachabilityForLocalWiFi

// Initialization methods

-(Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref
-(instancetype)initWithReachabilityRef:(SCNetworkReachabilityRef)ref
{
self = [super init];
if (self != nil)
Expand Down

0 comments on commit 472b00e

Please sign in to comment.