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; }