Skip to content
Permalink
Browse files

Merge pull request #3111 from AFNetworking/feature/unique_reachabilit…

…y_managers

Added a method to create a unique reachability manager
  • Loading branch information...
kcharwood committed Nov 6, 2015
2 parents ad6c7c3 + c093cd9 commit 95f09f0cabce36bf3ef959db4595adcecc0e78d6
Showing with 17 additions and 6 deletions.
  1. +7 −0 AFNetworking/AFNetworkReachabilityManager.h
  2. +10 −6 AFNetworking/AFNetworkReachabilityManager.m
@@ -81,6 +81,13 @@ NS_ASSUME_NONNULL_BEGIN
*/
+ (instancetype)sharedManager;

/**
Creates and returns a network reachability manager with the default socket address.
@return An initialized network reachability manager, actively monitoring the default socket address.
*/
+ (instancetype)manager;

/**
Creates and returns a network reachability manager for the specified domain.
@@ -115,12 +115,7 @@ + (instancetype)sharedManager {
static AFNetworkReachabilityManager *_sharedManager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
struct sockaddr_in address;
bzero(&address, sizeof(address));
address.sin_len = sizeof(address);
address.sin_family = AF_INET;

_sharedManager = [self managerForAddress:&address];
_sharedManager = [self manager];
});

return _sharedManager;
@@ -144,6 +139,15 @@ + (instancetype)managerForAddress:(const void *)address {
return manager;
}

+ (instancetype)manager
{
struct sockaddr_in address;
bzero(&address, sizeof(address));
address.sin_len = sizeof(address);
address.sin_family = AF_INET;
return [self managerForAddress:&address];
}

- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability {
self = [super init];
if (!self) {

0 comments on commit 95f09f0

Please sign in to comment.
You can’t perform that action at this time.