diff --git a/FastImageCache/FastImageCache/FastImageCache/FICEntity.h b/FastImageCache/FastImageCache/FastImageCache/FICEntity.h index 7e14cf8..5a4eccd 100644 --- a/FastImageCache/FastImageCache/FastImageCache/FICEntity.h +++ b/FastImageCache/FastImageCache/FastImageCache/FICEntity.h @@ -9,6 +9,8 @@ #import "FICImports.h" @class FICImageFormat; +NS_ASSUME_NONNULL_BEGIN + typedef void (^FICEntityImageDrawingBlock)(CGContextRef context, CGSize contextSize); /** @@ -52,7 +54,8 @@ typedef void (^FICEntityImageDrawingBlock)(CGContextRef context, CGSize contextS @see FICImageFormat @see [FICImageCacheDelegate imageCache:wantsSourceImageForEntity:withFormatName:completionBlock:] */ -- (NSURL *)fic_sourceImageURLWithFormatName:(NSString *)formatName; +- (nullable NSURL *)fic_sourceImageURLWithFormatName:(NSString *)formatName; + /** Returns the drawing block for a specific image and format name. @@ -73,7 +76,7 @@ typedef void (^FICEntityImageDrawingBlock)(CGContextRef context, CGSize contextS @note This block will always be called from the serial dispatch queue used by the image cache. */ -- (FICEntityImageDrawingBlock)fic_drawingBlockForImage:(UIImage *)image withFormatName:(NSString *)formatName; +- (nullable FICEntityImageDrawingBlock)fic_drawingBlockForImage:(UIImage *)image withFormatName:(NSString *)formatName; @optional /** @@ -81,6 +84,8 @@ typedef void (^FICEntityImageDrawingBlock)(CGContextRef context, CGSize contextS @param format The image format that identifies which image table is requesting the source image. */ -- (UIImage *)fic_imageForFormat:(FICImageFormat *)format; +- (nullable UIImage *)fic_imageForFormat:(FICImageFormat *)format; @end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/FastImageCache/FastImageCache/FastImageCache/FICImageCache.h b/FastImageCache/FastImageCache/FastImageCache/FICImageCache.h index dad29b7..bb102a0 100644 --- a/FastImageCache/FastImageCache/FastImageCache/FICImageCache.h +++ b/FastImageCache/FastImageCache/FastImageCache/FICImageCache.h @@ -13,8 +13,10 @@ @protocol FICEntity; @protocol FICImageCacheDelegate; -typedef void (^FICImageCacheCompletionBlock)(id entity, NSString *formatName, UIImage *image); -typedef void (^FICImageRequestCompletionBlock)(UIImage *sourceImage); +typedef void (^FICImageCacheCompletionBlock)(id _Nullable entity, NSString * _Nonnull formatName, UIImage * _Nullable image); +typedef void (^FICImageRequestCompletionBlock)(UIImage * _Nullable sourceImage); + +NS_ASSUME_NONNULL_BEGIN /** `FICImageCache` is the primary class for managing and interacting with the image cache. Applications using the image cache create one or more `` @@ -98,7 +100,7 @@ typedef void (^FICImageRequestCompletionBlock)(UIImage *sourceImage); @note Once the image formats have been set, subsequent calls to this method will do nothing. */ -- (void)setFormats:(NSArray *)formats; +- (void)setFormats:(NSArray *)formats; /** Returns an image format previously associated with the image cache. @@ -107,7 +109,7 @@ typedef void (^FICImageRequestCompletionBlock)(UIImage *sourceImage); @return An image format with the name `formatName` or `nil` if no format with that name exists. */ -- (FICImageFormat *)formatWithName:(NSString *)formatName; +- (nullable FICImageFormat *)formatWithName:(NSString *)formatName; /** Returns all the image formats of the same family previously associated with the image cache. @@ -116,7 +118,7 @@ typedef void (^FICImageRequestCompletionBlock)(UIImage *sourceImage); @return An array of `` objects whose family is `family` or `nil` if no format belongs to that family. */ -- (NSArray *)formatsWithFamily:(NSString *)family; +- (nullable NSArray *)formatsWithFamily:(NSString *)family; ///----------------------------------------------- /// @name Storing, Retrieving, and Deleting Images @@ -141,7 +143,7 @@ typedef void (^FICImageRequestCompletionBlock)(UIImage *sourceImage); typedef void (^FICImageCacheCompletionBlock)(id entity, NSString *formatName, UIImage *image) */ -- (void)setImage:(UIImage *)image forEntity:(id )entity withFormatName:(NSString *)formatName completionBlock:(FICImageCacheCompletionBlock)completionBlock; +- (void)setImage:(UIImage *)image forEntity:(id )entity withFormatName:(NSString *)formatName completionBlock:(nullable FICImageCacheCompletionBlock)completionBlock; /** Attempts to synchronously retrieve an image from the image cache. @@ -168,7 +170,7 @@ typedef void (^FICImageRequestCompletionBlock)(UIImage *sourceImage); @note You can always rely on the completion block being called. If an error occurs for any reason, the `image` parameter of the completion block will be `nil`. See <[FICImageCacheDelegate imageCache:errorDidOccurWithMessage:]> for information about being notified when errors occur. */ -- (BOOL)retrieveImageForEntity:(id )entity withFormatName:(NSString *)formatName completionBlock:(FICImageCacheCompletionBlock)completionBlock; +- (BOOL)retrieveImageForEntity:(id )entity withFormatName:(NSString *)formatName completionBlock:(nullable FICImageCacheCompletionBlock)completionBlock; /** Asynchronously retrieves an image from the image cache. @@ -193,7 +195,7 @@ typedef void (^FICImageRequestCompletionBlock)(UIImage *sourceImage); @see [FICImageCache retrieveImageForEntity:withFormatName:completionBlock:] */ -- (BOOL)asynchronouslyRetrieveImageForEntity:(id )entity withFormatName:(NSString *)formatName completionBlock:(FICImageCacheCompletionBlock)completionBlock; +- (BOOL)asynchronouslyRetrieveImageForEntity:(id )entity withFormatName:(NSString *)formatName completionBlock:(nullable FICImageCacheCompletionBlock)completionBlock; /** Deletes an image from the image cache. @@ -281,7 +283,7 @@ typedef void (^FICImageRequestCompletionBlock)(UIImage *sourceImage); the URL returned by <[FICEntity sourceImageURLWithFormatName:]>, deserializing the image data when the request completes, and finally calling this method's completion block to provide the image cache with the source image. */ -- (void)imageCache:(FICImageCache *)imageCache wantsSourceImageForEntity:(id )entity withFormatName:(NSString *)formatName completionBlock:(FICImageRequestCompletionBlock)completionBlock; +- (void)imageCache:(FICImageCache *)imageCache wantsSourceImageForEntity:(id )entity withFormatName:(NSString *)formatName completionBlock:(nullable FICImageRequestCompletionBlock)completionBlock; /** This method is called on the delegate when the image cache has received an image retrieval cancellation request. @@ -332,3 +334,5 @@ typedef void (^FICImageRequestCompletionBlock)(UIImage *sourceImage); - (void)imageCache:(FICImageCache *)imageCache errorDidOccurWithMessage:(NSString *)errorMessage; @end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/FastImageCache/FastImageCache/FastImageCache/FICImageFormat.h b/FastImageCache/FastImageCache/FastImageCache/FICImageFormat.h index a5b70b8..31304ef 100644 --- a/FastImageCache/FastImageCache/FastImageCache/FICImageFormat.h +++ b/FastImageCache/FastImageCache/FastImageCache/FICImageFormat.h @@ -34,6 +34,7 @@ typedef NS_ENUM(NSUInteger, FICImageFormatProtectionMode) { prevent the image cache from consuming too much disk space. Each `` managed by the image cache is associated with a single image format. */ +NS_ASSUME_NONNULL_BEGIN @interface FICImageFormat : NSObject ///------------------------------ @@ -152,7 +153,7 @@ typedef NS_ENUM(NSUInteger, FICImageFormatProtectionMode) { @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. */ -@property (nonatomic, copy, readonly) NSDictionary *dictionaryRepresentation; +@property (nonatomic, copy, readonly) NSDictionary *dictionaryRepresentation; ///----------------------------------- /// @name Initializing an Image Format @@ -180,3 +181,4 @@ typedef NS_ENUM(NSUInteger, FICImageFormatProtectionMode) { + (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 diff --git a/FastImageCache/FastImageCache/FastImageCache/FICImageTable.h b/FastImageCache/FastImageCache/FastImageCache/FICImageTable.h index 616f9ab..c4f542e 100644 --- a/FastImageCache/FastImageCache/FastImageCache/FICImageTable.h +++ b/FastImageCache/FastImageCache/FastImageCache/FICImageTable.h @@ -15,6 +15,8 @@ @class FICImageTableEntry; @class FICImage; +NS_ASSUME_NONNULL_BEGIN + extern NSString *const FICImageTableEntryDataVersionKey; extern NSString *const FICImageTableScreenScaleKey; @@ -81,7 +83,9 @@ extern NSString *const FICImageTableScreenScaleKey; @warning `FICImageTable` raises an exception if `imageFormat` is `nil`. `FICImageTable`'s implementation of `-init` simply calls through to this initializer, passing `nil` for `imageFormat`. */ -- (instancetype)initWithFormat:(FICImageFormat *)imageFormat imageCache:(FICImageCache *)imageCache; +- (nullable instancetype)initWithFormat:(FICImageFormat *)imageFormat imageCache:(FICImageCache *)imageCache NS_DESIGNATED_INITIALIZER; +-(instancetype) init __attribute__((unavailable("Invoke the designated initializer initWithFormat:imageCache: instead"))); ++(instancetype) new __attribute__((unavailable("Invoke the designated initializer initWithFormat:imageCache: instead"))); ///------------------------------------------------ /// @name Storing, Retrieving, and Deleting Entries @@ -123,7 +127,7 @@ extern NSString *const FICImageTableScreenScaleKey; @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 provided entity UUID, and `nil` is returned. */ -- (UIImage *)newImageForEntityUUID:(NSString *)entityUUID sourceImageUUID:(NSString *)sourceImageUUID preheatData:(BOOL)preheatData; +- (nullable UIImage *)newImageForEntityUUID:(NSString *)entityUUID sourceImageUUID:(NSString *)sourceImageUUID preheatData:(BOOL)preheatData; /** Deletes image entry data in the image table. @@ -164,3 +168,5 @@ extern NSString *const FICImageTableScreenScaleKey; - (void)reset; @end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/FastImageCache/FastImageCache/FastImageCache/FICImageTable.m b/FastImageCache/FastImageCache/FastImageCache/FICImageTable.m index b22cd1f..2925c02 100644 --- a/FastImageCache/FastImageCache/FastImageCache/FICImageTable.m +++ b/FastImageCache/FastImageCache/FastImageCache/FICImageTable.m @@ -233,10 +233,6 @@ - (instancetype)initWithFormat:(FICImageFormat *)imageFormat imageCache:(FICImag return self; } -- (instancetype)init { - return [self initWithFormat:nil imageCache:nil]; -} - - (void)dealloc { if (_fileDescriptor >= 0) { close(_fileDescriptor); diff --git a/FastImageCache/FastImageCache/FastImageCache/FICImageTableChunk.h b/FastImageCache/FastImageCache/FastImageCache/FICImageTableChunk.h index 53b0308..60fd8c5 100644 --- a/FastImageCache/FastImageCache/FastImageCache/FICImageTableChunk.h +++ b/FastImageCache/FastImageCache/FastImageCache/FICImageTableChunk.h @@ -8,6 +8,8 @@ #import "FICImports.h" +NS_ASSUME_NONNULL_BEGIN + @class FICImageTable; /** @@ -57,6 +59,8 @@ @return A new image table chunk. */ -- (instancetype)initWithFileDescriptor:(int)fileDescriptor index:(NSInteger)index length:(size_t)length; +- (nullable instancetype)initWithFileDescriptor:(int)fileDescriptor index:(NSInteger)index length:(size_t)length; + +@end -@end \ No newline at end of file +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/FastImageCache/FastImageCache/FastImageCache/FICImageTableEntry.h b/FastImageCache/FastImageCache/FastImageCache/FICImageTableEntry.h index a9ef850..2b8e8d9 100644 --- a/FastImageCache/FastImageCache/FastImageCache/FICImageTableEntry.h +++ b/FastImageCache/FastImageCache/FastImageCache/FICImageTableEntry.h @@ -8,6 +8,8 @@ #import "FICImports.h" +NS_ASSUME_NONNULL_BEGIN + @class FICImageTableChunk; @class FICImageCache; @@ -83,7 +85,7 @@ typedef struct { @return A new image table entry. */ -- (instancetype)initWithImageTableChunk:(FICImageTableChunk *)imageTableChunk bytes:(void *)bytes length:(size_t)length; +- (nullable instancetype)initWithImageTableChunk:(FICImageTableChunk *)imageTableChunk bytes:(void *)bytes length:(size_t)length; /** Adds a block to be executed when this image table entry is deallocated. @@ -122,3 +124,5 @@ typedef struct { + (NSInteger)metadataVersion; @end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/FastImageCache/FastImageCache/FastImageCache/FICUtilities.h b/FastImageCache/FastImageCache/FastImageCache/FICUtilities.h index d6292e6..62c6abe 100644 --- a/FastImageCache/FastImageCache/FastImageCache/FICUtilities.h +++ b/FastImageCache/FastImageCache/FastImageCache/FICUtilities.h @@ -11,7 +11,7 @@ size_t FICByteAlign(size_t bytesPerRow, size_t alignment); size_t FICByteAlignForCoreAnimation(size_t bytesPerRow); -NSString * FICStringWithUUIDBytes(CFUUIDBytes UUIDBytes); -CFUUIDBytes FICUUIDBytesWithString(NSString *string); -CFUUIDBytes FICUUIDBytesFromMD5HashOfString(NSString *MD5Hash); // Useful for computing an entity's UUID from a URL, for example +NSString * _Nullable FICStringWithUUIDBytes(CFUUIDBytes UUIDBytes); +CFUUIDBytes FICUUIDBytesWithString(NSString * _Nonnull string); +CFUUIDBytes FICUUIDBytesFromMD5HashOfString(NSString * _Nonnull MD5Hash); // Useful for computing an entity's UUID from a URL, for example