diff --git a/SUBasicUpdateDriver.m b/SUBasicUpdateDriver.m index d0143200..70ffb759 100644 --- a/SUBasicUpdateDriver.m +++ b/SUBasicUpdateDriver.m @@ -35,7 +35,6 @@ userAgent = [NSString stringWithCString:[cleanedAgent bytes] length:[cleanedAgent length]]; [appcast setUserAgentString:userAgent]; [appcast fetchAppcastFromURL:appcastURL]; - [host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey]; } - (id )_versionComparator diff --git a/SUUpdater.h b/SUUpdater.h index 9e922fbf..e78c4d35 100644 --- a/SUUpdater.h +++ b/SUUpdater.h @@ -51,11 +51,14 @@ // update is found, it will be downloaded and prepped for installation. - (void)checkForUpdatesInBackground; +// Date of last update check. Returns null if no check has been performed. +- (NSDate*)lastUpdateCheckDate; + // This begins a "probing" check for updates which will not actually offer to update to that version. The delegate methods, though, // (up to updater:didFindValidUpdate: and updaterDidNotFindUpdate:), are called, so you can use that information in your UI. - (void)checkForUpdateInformation; -// Call this to appropriately schedule or cancel the update checking timer according to the preferences for time interval and automatic checks. +// Call this to appropriately schedule or cancel the update checking timer according to the preferences for time interval and automatic checks. This call does not change the date of the next check, but only the internal NSTimer. - (void)resetUpdateCycle; - (BOOL)updateInProgress; diff --git a/SUUpdater.m b/SUUpdater.m index 7084f8c7..0179df98 100644 --- a/SUUpdater.m +++ b/SUUpdater.m @@ -138,6 +138,11 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv } } +- (NSDate *)lastUpdateCheckDate +{ + return [host objectForUserDefaultsKey:SULastCheckTimeKey]; +} + - (void)scheduleNextUpdateCheck { if (checkTimer) @@ -148,7 +153,7 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv if (![self automaticallyChecksForUpdates]) return; // How long has it been since last we checked for an update? - NSDate *lastCheckDate = [host objectForUserDefaultsKey:SULastCheckTimeKey]; + NSDate *lastCheckDate = [self lastUpdateCheckDate]; if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; } NSTimeInterval intervalSinceCheck = [[NSDate date] timeIntervalSinceDate:lastCheckDate]; @@ -183,6 +188,10 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv if ([self updateInProgress]) { return; } if (checkTimer) { [checkTimer invalidate]; checkTimer = nil; } + [self willChangeValueForKey:@"lastUpdateCheckDate"]; + [host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey]; + [self didChangeValueForKey:@"lastUpdateCheckDate"]; + driver = [d retain]; [driver checkForUpdatesAtURL:[self parameterizedFeedURL] host:host]; }