From 54e1e637bf2db8837fc378e2f43f63b11233ac81 Mon Sep 17 00:00:00 2001 From: Michael Fey Date: Tue, 16 Apr 2013 13:19:26 -0400 Subject: [PATCH] Refactor Reachability with a three-letter prefix. --- Reachability.h => TNMReachability.h | 18 +++++++++--------- Reachability.m => TNMReachability.m | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) rename Reachability.h => TNMReachability.h (84%) rename Reachability.m => TNMReachability.m (96%) diff --git a/Reachability.h b/TNMReachability.h similarity index 84% rename from Reachability.h rename to TNMReachability.h index 9febed8..4ce5dfe 100644 --- a/Reachability.h +++ b/TNMReachability.h @@ -58,12 +58,12 @@ 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; @@ -71,12 +71,12 @@ typedef void (^NetworkUnreachable)(Reachability * reachability); @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; diff --git a/Reachability.m b/TNMReachability.m similarity index 96% rename from Reachability.m rename to TNMReachability.m index c222e55..d736121 100644 --- a/Reachability.m +++ b/TNMReachability.m @@ -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; @@ -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 @@ -86,7 +86,7 @@ static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRea } -@implementation Reachability +@implementation TNMReachability @synthesize reachabilityRef; @synthesize reachabilitySerialQueue; @@ -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) @@ -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) @@ -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)); @@ -144,7 +144,7 @@ +(Reachability *)reachabilityForInternetConnection return [self reachabilityWithAddress:&zeroAddress]; } -+(Reachability*)reachabilityForLocalWiFi ++(TNMReachability*)reachabilityForLocalWiFi { struct sockaddr_in localWifiAddress; bzero(&localWifiAddress, sizeof(localWifiAddress)); @@ -159,7 +159,7 @@ +(Reachability*)reachabilityForLocalWiFi // initialization methods --(Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref +-(TNMReachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref { self = [super init]; if (self != nil)