From ea9496918843fd6c7796c0b957be245fe5806aa1 Mon Sep 17 00:00:00 2001 From: Kornel Date: Sun, 18 Mar 2018 13:51:26 +0000 Subject: [PATCH] 10.7 compatibility --- Sparkle/SPULocalCacheDirectory.m | 2 +- Sparkle/SPUURLRequest.m | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Sparkle/SPULocalCacheDirectory.m b/Sparkle/SPULocalCacheDirectory.m index 975ec1f062..c63f102f23 100755 --- a/Sparkle/SPULocalCacheDirectory.m +++ b/Sparkle/SPULocalCacheDirectory.m @@ -41,7 +41,7 @@ + (void)removeOldItemsInDirectory:(NSString *)directory NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:[directory stringByAppendingPathComponent:filename] error:NULL]; if (fileAttributes != nil) { - NSDate *lastModificationDate = fileAttributes[NSFileModificationDate]; + NSDate *lastModificationDate = [fileAttributes objectForKey:NSFileModificationDate]; if ([currentDate timeIntervalSinceDate:lastModificationDate] >= OLD_ITEM_DELETION_INTERVAL) { [filePathsToRemove addObject:[directory stringByAppendingPathComponent:filename]]; diff --git a/Sparkle/SPUURLRequest.m b/Sparkle/SPUURLRequest.m index f04f49984f..fad9fcd5bf 100755 --- a/Sparkle/SPUURLRequest.m +++ b/Sparkle/SPUURLRequest.m @@ -72,13 +72,17 @@ - (void)encodeWithCoder:(NSCoder *)coder - (instancetype)initWithCoder:(NSCoder *)decoder { - NSURL *url = [decoder decodeObjectOfClass:[NSURL class] forKey:SPUURLRequestURLKey]; - NSURLRequestCachePolicy cachePolicy = (NSURLRequestCachePolicy)[decoder decodeIntegerForKey:SPUURLRequestCachePolicyKey]; - NSTimeInterval timeoutInterval = [decoder decodeDoubleForKey:SPUURLRequestTimeoutIntervalKey]; - NSDictionary *httpHeaderFields = [decoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class], [NSString class]]] forKey:SPUURLRequestHttpHeaderFieldsKey]; - NSURLRequestNetworkServiceType networkServiceType = (NSURLRequestNetworkServiceType)[decoder decodeIntegerForKey:SPUURLRequestNetworkServiceTypeKey]; - - return [self initWithURL:url cachePolicy:cachePolicy timeoutInterval:timeoutInterval httpHeaderFields:httpHeaderFields networkServiceType:networkServiceType]; + if (@available(macOS 10.8, *)) { + NSURL *url = [decoder decodeObjectOfClass:[NSURL class] forKey:SPUURLRequestURLKey]; + NSURLRequestCachePolicy cachePolicy = (NSURLRequestCachePolicy)[decoder decodeIntegerForKey:SPUURLRequestCachePolicyKey]; + NSTimeInterval timeoutInterval = [decoder decodeDoubleForKey:SPUURLRequestTimeoutIntervalKey]; + NSDictionary *httpHeaderFields = [decoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class], [NSString class]]] forKey:SPUURLRequestHttpHeaderFieldsKey]; + NSURLRequestNetworkServiceType networkServiceType = (NSURLRequestNetworkServiceType)[decoder decodeIntegerForKey:SPUURLRequestNetworkServiceTypeKey]; + + return [self initWithURL:url cachePolicy:cachePolicy timeoutInterval:timeoutInterval httpHeaderFields:httpHeaderFields networkServiceType:networkServiceType]; + } else { + abort(); // Not used on 10.7 + } } - (NSURLRequest *)request