diff --git a/CHANGELOG.md b/CHANGELOG.md index e2970a68..7596a35f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 7.13.2 +- Remove synchronization delay for `GULUserDefaults` to better match + `NSUserDefaults` behavior. (#148) + # 7.13.1 (SwiftPM Only) - Attempt to fix validation error due to invalid module name. (#146) diff --git a/GoogleUtilities.podspec b/GoogleUtilities.podspec index f9141e81..f0a03ab0 100644 --- a/GoogleUtilities.podspec +++ b/GoogleUtilities.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GoogleUtilities' - s.version = '7.13.0' + s.version = '7.13.2' s.summary = 'Google Utilities for Apple platform SDKs' s.description = <<-DESC diff --git a/GoogleUtilities/UserDefaults/GULUserDefaults.m b/GoogleUtilities/UserDefaults/GULUserDefaults.m index 1640d6ed..6c45048a 100644 --- a/GoogleUtilities/UserDefaults/GULUserDefaults.m +++ b/GoogleUtilities/UserDefaults/GULUserDefaults.m @@ -18,8 +18,6 @@ NS_ASSUME_NONNULL_BEGIN -static NSTimeInterval const kGULSynchronizeInterval = 1.0; - static NSString *const kGULLogFormat = @"I-GUL%06ld"; static GULLoggerService kGULLogUserDefaultsService = @"[GoogleUtilities/UserDefaults]"; @@ -107,7 +105,7 @@ - (void)setObject:(nullable id)value forKey:(NSString *)defaultName { } if (!value) { CFPreferencesSetAppValue((__bridge CFStringRef)key, NULL, _appNameRef); - [self scheduleSynchronize]; + [self synchronize]; return; } BOOL isAcceptableValue = @@ -124,7 +122,7 @@ - (void)setObject:(nullable id)value forKey:(NSString *)defaultName { } CFPreferencesSetAppValue((__bridge CFStringRef)key, (__bridge CFStringRef)value, _appNameRef); - [self scheduleSynchronize]; + [self synchronize]; } - (void)removeObjectForKey:(NSString *)key { @@ -193,21 +191,6 @@ - (void)synchronize { } } -#pragma mark - Private methods - -- (void)scheduleSynchronize { - // Synchronize data using a timer so that multiple set... calls can be coalesced under one - // synchronize. - [NSObject cancelPreviousPerformRequestsWithTarget:self - selector:@selector(synchronize) - object:nil]; - // This method may be called on multiple queues (due to set... methods can be called on any queue) - // synchronize can be scheduled on different queues, so make sure that it does not crash. If this - // instance goes away, self will be released also, no one will retain it and the schedule won't be - // called. - [self performSelector:@selector(synchronize) withObject:nil afterDelay:kGULSynchronizeInterval]; -} - @end NS_ASSUME_NONNULL_END