diff --git a/FastImageCache/FastImageCache/FastImageCache/FICImageFormat.h b/FastImageCache/FastImageCache/FastImageCache/FICImageFormat.h index 31304ef..cc90a31 100644 --- a/FastImageCache/FastImageCache/FastImageCache/FICImageFormat.h +++ b/FastImageCache/FastImageCache/FastImageCache/FICImageFormat.h @@ -147,6 +147,8 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, assign, readonly) NSString *protectionModeString; +@property (nonatomic, assign, readonly) NSDataWritingOptions protectionModeOption; + /** The dictionary representation of this image format. @@ -181,4 +183,4 @@ NS_ASSUME_NONNULL_BEGIN + (instancetype)formatWithName:(NSString *)name family:(NSString *)family imageSize:(CGSize)imageSize style:(FICImageFormatStyle)style maximumCount:(NSInteger)maximumCount devices:(FICImageFormatDevices)devices protectionMode:(FICImageFormatProtectionMode)protectionMode; @end -NS_ASSUME_NONNULL_END \ No newline at end of file +NS_ASSUME_NONNULL_END diff --git a/FastImageCache/FastImageCache/FastImageCache/FICImageFormat.m b/FastImageCache/FastImageCache/FastImageCache/FICImageFormat.m index da6eeca..8d7c4ce 100644 --- a/FastImageCache/FastImageCache/FastImageCache/FICImageFormat.m +++ b/FastImageCache/FastImageCache/FastImageCache/FICImageFormat.m @@ -143,6 +143,22 @@ - (NSString *)protectionModeString { return protectionModeString; } +- (NSDataWritingOptions)protectionModeOption { + NSDataWritingOptions protectionModeOption = NSDataWritingFileProtectionNone; + switch (_protectionMode) { + case FICImageFormatProtectionModeNone: + protectionModeOption = NSDataWritingFileProtectionNone; + break; + case FICImageFormatProtectionModeComplete: + protectionModeOption = NSDataWritingFileProtectionComplete; + break; + case FICImageFormatProtectionModeCompleteUntilFirstUserAuthentication: + protectionModeOption = NSDataWritingFileProtectionCompleteUntilFirstUserAuthentication; + break; + } + return protectionModeOption; +} + #pragma mark - Object Lifecycle + (instancetype)formatWithName:(NSString *)name family:(NSString *)family imageSize:(CGSize)imageSize style:(FICImageFormatStyle)style maximumCount:(NSInteger)maximumCount devices:(FICImageFormatDevices)devices protectionMode:(FICImageFormatProtectionMode)protectionMode { diff --git a/FastImageCache/FastImageCache/FastImageCache/FICImageTable.m b/FastImageCache/FastImageCache/FastImageCache/FICImageTable.m index 2925c02..234ecf1 100644 --- a/FastImageCache/FastImageCache/FastImageCache/FICImageTable.m +++ b/FastImageCache/FastImageCache/FastImageCache/FICImageTable.m @@ -714,7 +714,7 @@ - (void)saveMetadata { return; } - BOOL fileWriteResult = [data writeToFile:[self metadataFilePath] atomically:NO]; + BOOL fileWriteResult = [data writeToFile:[self metadataFilePath] options:[_imageFormat protectionModeOption] error:nil]; if (fileWriteResult == NO) { NSString *message = [NSString stringWithFormat:@"*** FIC Error: %s couldn't write metadata for format %@", __PRETTY_FUNCTION__, [_imageFormat name]]; [self.imageCache _logMessage:message];