Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored Reachability with a three-letter prefix #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Reachability.h → TNMReachability.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,25 @@ typedef enum
ReachableViaWWAN = 1
} NetworkStatus;

@class Reachability;
@class TNMReachability;

typedef void (^NetworkReachable)(Reachability * reachability);
typedef void (^NetworkUnreachable)(Reachability * reachability);
typedef void (^NetworkReachable)(TNMReachability * reachability);
typedef void (^NetworkUnreachable)(TNMReachability * reachability);

@interface Reachability : NSObject
@interface TNMReachability : NSObject

@property (nonatomic, copy) NetworkReachable reachableBlock;
@property (nonatomic, copy) NetworkUnreachable unreachableBlock;


@property (nonatomic, assign) BOOL reachableOnWWAN;

+(Reachability*)reachabilityWithHostname:(NSString*)hostname;
+(Reachability*)reachabilityForInternetConnection;
+(Reachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
+(Reachability*)reachabilityForLocalWiFi;
+(TNMReachability*)reachabilityWithHostname:(NSString*)hostname;
+(TNMReachability*)reachabilityForInternetConnection;
+(TNMReachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
+(TNMReachability*)reachabilityForLocalWiFi;

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

-(BOOL)startNotifier;
-(void)stopNotifier;
Expand Down
20 changes: 10 additions & 10 deletions Reachability.m → TNMReachability.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
POSSIBILITY OF SUCH DAMAGE.
*/

#import "Reachability.h"
#import "TNMReachability.h"


NSString *const kReachabilityChangedNotification = @"kReachabilityChangedNotification";

@interface Reachability ()
@interface TNMReachability ()

@property (nonatomic, assign) SCNetworkReachabilityRef reachabilityRef;

Expand Down Expand Up @@ -72,9 +72,9 @@ static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRea
{
#pragma unused (target)
#if __has_feature(objc_arc)
Reachability *reachability = ((__bridge Reachability*)info);
TNMReachability *reachability = ((__bridge TNMReachability*)info);
#else
Reachability *reachability = ((Reachability*)info);
TNMReachability *reachability = ((TNMReachability*)info);
#endif

// we probably dont need an autoreleasepool here as GCD docs state each queue has its own autorelease pool
Expand All @@ -86,7 +86,7 @@ static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRea
}


@implementation Reachability
@implementation TNMReachability

@synthesize reachabilityRef;
@synthesize reachabilitySerialQueue;
Expand All @@ -99,7 +99,7 @@ @implementation Reachability
@synthesize reachabilityObject;

#pragma mark - class constructor methods
+(Reachability*)reachabilityWithHostname:(NSString*)hostname
+(TNMReachability*)reachabilityWithHostname:(NSString*)hostname
{
SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithName(NULL, [hostname UTF8String]);
if (ref)
Expand All @@ -117,7 +117,7 @@ +(Reachability*)reachabilityWithHostname:(NSString*)hostname
return nil;
}

+(Reachability *)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress
+(TNMReachability *)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress
{
SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);
if (ref)
Expand All @@ -134,7 +134,7 @@ +(Reachability *)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress
return nil;
}

+(Reachability *)reachabilityForInternetConnection
+(TNMReachability *)reachabilityForInternetConnection
{
struct sockaddr_in zeroAddress;
bzero(&zeroAddress, sizeof(zeroAddress));
Expand All @@ -144,7 +144,7 @@ +(Reachability *)reachabilityForInternetConnection
return [self reachabilityWithAddress:&zeroAddress];
}

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

// initialization methods

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