--- a/Frameworks/AIUtilities Framework/Source/AIHostReachabilityMonitor.h Sat Apr 05 15:53:18 2014 -0400
+++ b/Frameworks/AIUtilities Framework/Source/AIHostReachabilityMonitor.h Mon Jan 20 13:48:06 2014 -0500
@@ -28,6 +28,8 @@
NSMutableArray *observers;
NSMutableArray *reachabilities;
+ NSMutableArray *AI_hostsBeforeSleep; + NSMutableArray *AI_observersBeforeSleep; NSMutableSet *unconfiguredHostsAndObservers;
--- a/Frameworks/AIUtilities Framework/Source/AIHostReachabilityMonitor.m Sat Apr 05 15:53:18 2014 -0400
+++ b/Frameworks/AIUtilities Framework/Source/AIHostReachabilityMonitor.m Mon Jan 20 13:48:06 2014 -0500
@@ -34,10 +34,16 @@
- (void)beginMonitorngIPChanges;
- (void)stopMonitoringIPChanges;
+@property (nonatomic, copy) NSArray *AI_hostsBeforeSleep; +@property (nonatomic, copy) NSArray *AI_observersBeforeSleep; +- (void)systemWillSleep:(NSNotification *)notification; - (void)systemDidWake:(NSNotification *)notification;
@implementation AIHostReachabilityMonitor
+@synthesize AI_hostsBeforeSleep, AI_observersBeforeSleep; #pragma mark Shared instance management
@@ -80,6 +86,11 @@
selector:@selector(systemDidWake:)
name:AISystemDidWake_Notification
+ [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(systemWillSleep:) + name:AISystemWillSleep_Notification @@ -93,6 +104,8 @@
[hosts release]; hosts = nil;
[observers release]; observers = nil;
[reachabilities release]; reachabilities = nil;
+ [AI_hostsBeforeSleep release]; AI_hostsBeforeSleep = nil; + [AI_observersBeforeSleep release]; AI_observersBeforeSleep = nil; [unconfiguredHostsAndObservers release]; unconfiguredHostsAndObservers = nil;
[hostAndObserverListLock unlock];
@@ -625,22 +638,26 @@
CFRelease(ipChangesRunLoopSourceRef);
ipChangesRunLoopSourceRef = nil;
+ self.AI_hostsBeforeSleep = nil; + self.AI_observersBeforeSleep = nil; #pragma mark Sleep and Wake
- * @brief System is waking from sleep
+ * @brief System will go into sleep - * When the system wakes, manually reconfigure reachability checking as not all network configurations will report a change.
+ * Before the system sleeps, unschedule reachability checking, and back up a copy of the hosts and observers to + * re-configure reachability for when the system wakes up -- (void)systemDidWake:(NSNotification *)notification
+- (void)systemWillSleep:(NSNotification *)notification [hostAndObserverListLock lock];
- NSArray *oldHosts = [hosts copy];
- NSArray *oldObservers = [observers copy];
+ self.AI_hostsBeforeSleep = hosts; + self.AI_observersBeforeSleep = observers; NSEnumerator *enumerator;
SCNetworkReachabilityRef reachabilityRef;
@@ -656,7 +673,17 @@
[reachabilities removeAllObjects];
[hostAndObserverListLock unlock];
+ * @brief System is waking from sleep + * When the system wakes, manually reconfigure reachability checking as not all network configurations will report a change. +- (void)systemDidWake:(NSNotification *)notification + NSArray *oldHosts = self.AI_hostsBeforeSleep; + NSArray *oldObservers = self.AI_observersBeforeSleep; NSUInteger numObservers = [oldObservers count];
for (unsigned i = 0; i < numObservers; i++) {
NSString *host = [oldHosts objectAtIndex:i];
@@ -666,8 +693,8 @@
- [oldObservers release];
+ self.AI_hostsBeforeSleep = nil; + self.AI_observersBeforeSleep = nil;