From 19c277d68e182b0946fab80339f0d1780c9f3c23 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 4 Apr 2024 17:33:05 -0400 Subject: [PATCH] Digital PCT265 story MVAPCT-48 - exposing constants. --- MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h | 3 +++ MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h index 6319fa5..5d2a48c 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h @@ -12,6 +12,9 @@ #import @class MVMCoreErrorObject; +extern NSString * _Nonnull const KeyCachePolicy; +extern NSString * _Nonnull const KeyCacheExpiry; + //block returned when getting image //parameters are UIImage object for the image, NSData for gif images, UIImage object for the image, A BOOL to indicate if it is a fall back image. typedef void(^MVMCoreGetImageBlock)(UIImage * _Nullable, NSData * _Nullable, BOOL); diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m index 3f1fa92..f2af3c3 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m @@ -17,6 +17,9 @@ #import "MVMCoreErrorConstants.h" #import "MVMCoreLoggingHandlerHelper.h" +NSString * _Nonnull const KeyCachePolicy = @"cachePolicy"; +NSString * _Nonnull const KeyCacheExpiry = @"expiry"; + @interface MVMCoreCache () // The cache for json. @@ -113,13 +116,13 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; } - (nonnull NSDate *)getExpirationDateForJSON:(nonnull NSDictionary *)jsonDictionary { - NSDictionary *cachePolicy = [jsonDictionary dict:@"cachePolicy"]; - NSTimeInterval interval = [[cachePolicy string:@"expiry"] doubleValue] / 1000; + NSDictionary *cachePolicy = [jsonDictionary dict:KeyCachePolicy]; + NSTimeInterval interval = [[cachePolicy string:KeyCacheExpiry] doubleValue] / 1000; return [NSDate dateWithTimeIntervalSince1970:interval]; } - (BOOL)shouldPersistentlyCacheJSON:(nonnull NSDictionary *)jsonDictionary { - NSDictionary *cachePolicy = [jsonDictionary dict:@"cachePolicy"]; + NSDictionary *cachePolicy = [jsonDictionary dict:KeyCachePolicy]; if (!cachePolicy || ![cachePolicy boolForKey:@"persist"]) { return NO; }