Skip to content

Commit 85d7e01

Browse files
author
Michael Potter
committed
Update documentation
1 parent 1c457cb commit 85d7e01

File tree

7 files changed

+85
-18
lines changed

7 files changed

+85
-18
lines changed

FastImageCache/FICImageCache.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,24 @@ typedef void (^FICImageRequestCompletionBlock)(UIImage *sourceImage);
4141
///---------------------------------------
4242

4343
/**
44-
Convenience accessor to retrieve a shared image cache instance.
44+
Returns the shared image cache.
45+
46+
@return A shared instance of `FICImageCache`.
47+
48+
@note Fast Image Cache can either be used as a singleton for convenience or can exist as multiple instances. However, all instances of `FICImageCache` will make use of
49+
shared resources, such as the same dispatch queue and the same location on disk for storing image tables.
50+
51+
@see [FICImageCache dispatchQueue]
4552
*/
4653
+ (instancetype)sharedImageCache;
4754

55+
/**
56+
Returns the shared dispatch queue used by all instances of `FICImageCache`.
57+
58+
@return A generic, shared dispatch queue of type `dispatch_queue_t`.
59+
60+
@note All instances of `FICImageCache` make use a single, shared dispatch queue to do their work.
61+
*/
4862
+ (dispatch_queue_t)dispatchQueue;
4963

5064
///---------------------------------

FastImageCache/FICImageFormat.h

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ typedef NS_OPTIONS(NSUInteger, FICImageFormatDevices) {
1515
FICImageFormatDevicePad = 1 << UIUserInterfaceIdiomPad,
1616
};
1717

18-
typedef NS_OPTIONS(NSUInteger, FICImageFormatStyle) {
18+
typedef NS_ENUM(NSUInteger, FICImageFormatStyle) {
1919
FICImageFormatStyle32BitBGRA,
2020
FICImageFormatStyle32BitBGR,
2121
FICImageFormatStyle16BitBGR,
2222
FICImageFormatStyle8BitGrayscale,
2323
};
2424

25-
typedef NS_OPTIONS(NSUInteger, FICImageFormatProtectionMode) {
25+
typedef NS_ENUM(NSUInteger, FICImageFormatProtectionMode) {
2626
FICImageFormatProtectionModeNone,
2727
FICImageFormatProtectionModeComplete,
2828
FICImageFormatProtectionModeCompleteUntilFirstUserAuthentication,
@@ -42,6 +42,9 @@ typedef NS_OPTIONS(NSUInteger, FICImageFormatProtectionMode) {
4242

4343
/**
4444
The name of the image format. Each image format must have a unique name.
45+
46+
@note Since multiple instances of Fast Image Cache can exist in the same application, it is important that image format name's be unique across all instances of `<FICImageCache>`. Reverse DNS naming
47+
is recommended (e.g., com.path.PTUserProfilePhotoLargeImageFormat).
4548
*/
4649
@property (nonatomic, copy) NSString *name;
4750

@@ -120,14 +123,34 @@ typedef NS_OPTIONS(NSUInteger, FICImageFormatProtectionMode) {
120123
*/
121124
@property (nonatomic, assign, readonly) BOOL isGrayscale;
122125

123-
126+
/**
127+
The data protection mode that image table files will be created with.
128+
129+
`FICImageFormatProtectionMode` has the following values:
130+
131+
- `FICImageFormatProtectionModeNone`: No data protection is used. The image table file backing this image format will always be available for reading and writing.
132+
- `FICImageFormatProtectionModeComplete`: Complete data protection is used. As soon as the system enables data protection (i.e., when the device is locked), the image table file backing this image
133+
format will not be available for reading and writing. As a result, images of this format should not be requested by Fast Image Cache when executing backgrounded code.
134+
- `FICImageFormatProtectionModeCompleteUntilFirstUserAuthentication`: Partial data protection is used. After a device restart, until the user unlocks the device for the first time, complete data
135+
protection is in effect. However, after the device has been unlocked for the first time, the image table file backing this image format will remain available for readin and writing. This mode may be
136+
a good compromise between encrypting image table files after the device powers down and allowing the files to be accessed successfully by Fast Image Cache, whether or not the device is subsequently
137+
locked.
138+
139+
@note Data protection can prevent Fast Image Cache from accessing its image table files to read and write image data. If the image data being stored in Fast Image Cache is not sensitive in nature,
140+
consider using `FICImageFormatProtectionModeNone` to prevent any issues accessing image table files when the disk is encrypted.
141+
*/
124142
@property (nonatomic, assign) FICImageFormatProtectionMode protectionMode;
143+
144+
/**
145+
The string representation of `<protectionMode>`.
146+
*/
125147
@property (nonatomic, assign, readonly) NSString *protectionModeString;
126148

127149
/**
128150
The dictionary representation of this image format.
129151
130-
@discussion Fast Image Cache automatically serializes the image formats that it uses to disk. If an image format ever changes, Fast Image Cache automatically detects the change and invalidates the image table associated with that image format. The image table is then recreated from the updated image format.
152+
@discussion Fast Image Cache automatically serializes the image formats that it uses to disk. If an image format ever changes, Fast Image Cache automatically detects the change and invalidates the
153+
image table associated with that image format. The image table is then recreated from the updated image format.
131154
*/
132155
@property (nonatomic, copy, readonly) NSDictionary *dictionaryRepresentation;
133156

@@ -150,7 +173,9 @@ typedef NS_OPTIONS(NSUInteger, FICImageFormatProtectionMode) {
150173
151174
@param devices A bitmask of type `<FICImageFormatDevices>` that defines which devices are managed by an image table.
152175
153-
@return An autoreleased instance of `<FICImageFormat>` or one of its subclasses, if any exist.
176+
@param protectionMode The data protection mode to use when creating the backing image table file for this image format. See the `<protectionMode>` property description for more information.
177+
178+
@return An autoreleased instance of `FICImageFormat` or one of its subclasses, if any exist.
154179
*/
155180
+ (instancetype)formatWithName:(NSString *)name family:(NSString *)family imageSize:(CGSize)imageSize style:(FICImageFormatStyle)style maximumCount:(NSInteger)maximumCount devices:(FICImageFormatDevices)devices protectionMode:(FICImageFormatProtectionMode)protectionMode;
156181

FastImageCache/FICImageTable.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ extern NSString *const FICImageTableScreenScaleKey;
7575
7676
@param imageFormat The image format that describes the image table.
7777
78+
@param imageCache The instance of `<FICImageCache>` that owns this image table.
79+
7880
@return A new image table.
7981
8082
@warning `FICImageTable` raises an exception if `imageFormat` is `nil`. `FICImageTable`'s implementation of `-init` simply calls through to this initializer, passing `nil` for `imageFormat`.
@@ -110,11 +112,13 @@ extern NSString *const FICImageTableScreenScaleKey;
110112
111113
@param sourceImageUUID The UUID of the source image that represents the actual image data stored in an image table entry. Must not be `nil`.
112114
115+
@param preheatData A `BOOL` indicating whether or not the entry's image data should be preheated. See `<[FICImageTableEntry preheat]>` for more information.
116+
113117
@return A new image created from the entry data stored in the image table or `nil` if something went wrong.
114118
115119
@discussion The `UIImage` returned by this method is initialized by a `CGImageRef` backed directly by mapped file data, so no memory copy occurs.
116120
117-
@note If either of the parameters to this method are `nil`, the return value is `nil`.
121+
@note If either of the first two parameters to this method are `nil`, the return value is `nil`.
118122
119123
@note If either the entity UUID or the source image UUID doesn't match the corresponding UUIDs in the entry data, then something has changed. The entry data is deleted for the
120124
provided entity UUID, and `nil` is returned.

FastImageCache/FICImageTable.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ @interface FICImageTable () {
6666
NSString *_fileDataProtectionMode;
6767
BOOL _canAccessData;
6868
}
69-
@property(nonatomic, weak) FICImageCache *imageCache;
69+
70+
@property (nonatomic, weak) FICImageCache *imageCache;
71+
7072
@end
7173

7274
#pragma mark

FastImageCache/FICImageTableChunk.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
*/
3737
@property (nonatomic, assign, readonly) off_t fileOffset;
3838

39+
/**
40+
The length, in bytes, of the chunk.
41+
*/
3942
@property (nonatomic, assign, readonly) size_t length;
4043

4144

FastImageCache/FICImageTableEntry.h

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,24 @@ typedef struct {
5353
*/
5454
@property (nonatomic, assign) CFUUIDBytes sourceImageUUIDBytes;
5555

56+
/**
57+
The image table chunk that contains this entry.
58+
*/
5659
@property (nonatomic, readonly) FICImageTableChunk *imageTableChunk;
5760

61+
/**
62+
A weak reference to the image cache that contains the image table chunk that contains this entry.
63+
*/
5864
@property (nonatomic, weak) FICImageCache *imageCache;
5965

66+
/**
67+
The index where this entry exists in the image table.
68+
*/
6069
@property (nonatomic, assign) NSInteger index;
6170

62-
- (void)preheat;
63-
64-
///----------------------------------------
65-
/// @name Initializing an Image Table Entry
66-
///----------------------------------------
71+
///----------------------------------
72+
/// @name Image Table Entry Lifecycle
73+
///----------------------------------
6774

6875
/**
6976
Initializes a new image table entry from an image table chunk.
@@ -78,8 +85,20 @@ typedef struct {
7885
*/
7986
- (instancetype)initWithImageTableChunk:(FICImageTableChunk *)imageTableChunk bytes:(void *)bytes length:(size_t)length;
8087

88+
/**
89+
Adds a block to be executed when this image table entry is deallocated.
90+
91+
@param block A block that will be called when this image table entry is deallocated.
92+
93+
@note Because of the highly-concurrent nature of Fast Image Cache, image tables must know when any of their entries are about to be deallocated to disassociate them with its internal data structures.
94+
*/
8195
- (void)executeBlockOnDealloc:(dispatch_block_t)block;
8296

97+
/**
98+
Forces the kernel to page in the memory-mapped, on-disk data backing this entry right away.
99+
*/
100+
- (void)preheat;
101+
83102
///--------------------------------------------
84103
/// @name Flushing a Modified Image Table Entry
85104
///--------------------------------------------

FastImageCacheDemo/Classes/FICDPhoto.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
NSString *const FICDPhotoImageFormatFamily = @"FICDPhotoImageFormatFamily";
1515

16-
NSString *const FICDPhotoSquareImage32BitBGRAFormatName = @"FICDPhotoSquareImage32BitBGRAFormatName";
17-
NSString *const FICDPhotoSquareImage32BitBGRFormatName = @"FICDPhotoSquareImage32BitBGRFormatName";
18-
NSString *const FICDPhotoSquareImage16BitBGRFormatName = @"FICDPhotoSquareImage16BitBGRFormatName";
19-
NSString *const FICDPhotoSquareImage8BitGrayscaleFormatName = @"FICDPhotoSquareImage8BitGrayscaleFormatName";
20-
NSString *const FICDPhotoPixelImageFormatName = @"FICDPhotoPixelImageFormatName";
16+
NSString *const FICDPhotoSquareImage32BitBGRAFormatName = @"com.path.FastImageCacheDemo.FICDPhotoSquareImage32BitBGRAFormatName";
17+
NSString *const FICDPhotoSquareImage32BitBGRFormatName = @"com.path.FastImageCacheDemo.FICDPhotoSquareImage32BitBGRFormatName";
18+
NSString *const FICDPhotoSquareImage16BitBGRFormatName = @"com.path.FastImageCacheDemo.FICDPhotoSquareImage16BitBGRFormatName";
19+
NSString *const FICDPhotoSquareImage8BitGrayscaleFormatName = @"com.path.FastImageCacheDemo.FICDPhotoSquareImage8BitGrayscaleFormatName";
20+
NSString *const FICDPhotoPixelImageFormatName = @"com.path.FastImageCacheDemo.FICDPhotoPixelImageFormatName";
2121

2222
CGSize const FICDPhotoSquareImageSize = {75, 75};
2323
CGSize const FICDPhotoPixelImageSize = {1, 1};

0 commit comments

Comments
 (0)