Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding protection mode while writing content to the file #145

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions FastImageCache.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

Pod::Spec.new do |s|

s.name = "FastImageCache"
s.version = "1.5.1"
s.summary = "iOS library for quickly displaying images while scrolling"

s.description = <<-DESC
Fast Image Cache is an efficient, persistent, and—above all—fast way to store and retrieve images in your iOS application. Part of any good iOS application's user experience is fast, smooth scrolling, and Fast Image Cache helps make this easier.
A significant burden on performance for graphics-rich applications like Path is image loading. The traditional method of loading individual images from disk is just too slow, especially while scrolling. Fast Image Cache was created specifically to solve this problem.
DESC

s.homepage = "https://github.com/gauravmnit07/FastImageCache"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.authors = { "Mallory Paine" => "[email protected]", "Michael Potter" => "[email protected]" }

s.platform = :ios
s.platform = :ios, '6.0'
s.source = { :git => "https://github.com/gauravmnit07/FastImageCache.git" }

s.source_files = "FastImageCache/FastImageCache/**/*.{h,m}"
s.requires_arc = true

end
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
NS_ASSUME_NONNULL_END
16 changes: 16 additions & 0 deletions FastImageCache/FastImageCache/FastImageCache/FICImageFormat.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down