Browse Source

Merge pull request #142 from Rabursky/feature/custom-notification-center

Custom notificationCenter option added
Ashley Mills 9 years ago
parent
commit
610027bd13
1 changed files with 4 additions and 1 deletions
  1. 4 1
      Reachability/Reachability.swift

+ 4 - 1
Reachability/Reachability.swift

@@ -71,6 +71,9 @@ public class Reachability {
     public var whenReachable: NetworkReachable?
     public var whenUnreachable: NetworkUnreachable?
     public var reachableOnWWAN: Bool
+    
+    // The notification center on which "reachability changed" events are being posted
+    public var notificationCenter: NotificationCenter = NotificationCenter.default
 
     public var currentReachabilityString: String {
         return "\(currentReachabilityStatus)"
@@ -236,7 +239,7 @@ fileprivate extension Reachability {
         let block = isReachable ? whenReachable : whenUnreachable
         block?(self)
         
-        NotificationCenter.default.post(name: ReachabilityChangedNotification, object:self)
+        self.notificationCenter.post(name: ReachabilityChangedNotification, object:self)
         
         previousFlags = flags
     }