diff --git a/YYWebImage/YYWebImageManager.h b/YYWebImage/YYWebImageManager.h index 6947faf..9c9d803 100644 --- a/YYWebImage/YYWebImageManager.h +++ b/YYWebImage/YYWebImageManager.h @@ -23,54 +23,54 @@ NS_ASSUME_NONNULL_BEGIN /// The options to control image operation. typedef NS_OPTIONS(NSUInteger, YYWebImageOptions) { - + /// Show network activity on status bar when download image. YYWebImageOptionShowNetworkActivity = 1 << 0, - + /// Display progressive/interlaced/baseline image during download (same as web browser). YYWebImageOptionProgressive = 1 << 1, - + /// Display blurred progressive JPEG or interlaced PNG image during download. /// This will ignore baseline image for better user experience. YYWebImageOptionProgressiveBlur = 1 << 2, - + /// Use NSURLCache instead of YYImageCache. YYWebImageOptionUseNSURLCache = 1 << 3, - + /// Allows untrusted SSL ceriticates. YYWebImageOptionAllowInvalidSSLCertificates = 1 << 4, - + /// Allows background task to download image when app is in background. YYWebImageOptionAllowBackgroundTask = 1 << 5, - + /// Handles cookies stored in NSHTTPCookieStore. YYWebImageOptionHandleCookies = 1 << 6, - + /// Load the image from remote and refresh the image cache. YYWebImageOptionRefreshImageCache = 1 << 7, - + /// Do not load image from/to disk cache. YYWebImageOptionIgnoreDiskCache = 1 << 8, - + /// Do not change the view's image before set a new URL to it. YYWebImageOptionIgnorePlaceHolder = 1 << 9, - + /// Ignore image decoding. /// This may used for image downloading without display. YYWebImageOptionIgnoreImageDecoding = 1 << 10, - + /// Ignore multi-frame image decoding. /// This will handle the GIF/APNG/WebP/ICO image as single frame image. YYWebImageOptionIgnoreAnimatedImage = 1 << 11, - + /// Set the image to view with a fade animation. /// This will add a "fade" animation on image view's layer for better user experience. YYWebImageOptionSetImageWithFadeAnimation = 1 << 12, - + /// Do not set the image to the view when image fetch complete. /// You may set the image manually. YYWebImageOptionAvoidSetImage = 1 << 13, - + /// This flag will add the URL to a blacklist (in memory) when the URL fail to be downloaded, /// so the library won't keep trying. YYWebImageOptionIgnoreFailedURL = 1 << 14, @@ -78,34 +78,34 @@ typedef NS_OPTIONS(NSUInteger, YYWebImageOptions) { /// Indicated where the image came from. typedef NS_ENUM(NSUInteger, YYWebImageFromType) { - + /// No value. YYWebImageFromNone = 0, - + /// Fetched from memory cache immediately. /// If you called "setImageWithURL:..." and the image is already in memory, /// then you will get this value at the same call. YYWebImageFromMemoryCacheFast, - + /// Fetched from memory cache. YYWebImageFromMemoryCache, - + /// Fetched from disk cache. YYWebImageFromDiskCache, - + /// Fetched from remote (web or file path). YYWebImageFromRemote, }; /// Indicated image fetch complete stage. typedef NS_ENUM(NSInteger, YYWebImageStage) { - + /// Incomplete, progressive image. YYWebImageStageProgress = -1, - + /// Cancelled. YYWebImageStageCancelled = 0, - + /// Finished (succeed or failed). YYWebImageStageFinished = 1, }; @@ -113,7 +113,7 @@ typedef NS_ENUM(NSInteger, YYWebImageStage) { /** The block invoked in remote image fetch progress. - + @param receivedSize Current received size in bytes. @param expectedSize Expected total size in bytes (-1 means unknown). */ @@ -121,11 +121,11 @@ typedef void(^YYWebImageProgressBlock)(NSInteger receivedSize, NSInteger expecte /** The block invoked before remote image fetch finished to do additional image process. - + @discussion This block will be invoked before `YYWebImageCompletionBlock` to give you a chance to do additional image process (such as resize or crop). If there's no need to transform the image, just return the `image` parameter. - + @example You can clip the image, blur it and add rounded corners with these code: ^(UIImage *image, NSURL *url) { // Maybe you need to create an @autoreleasepool to limit memory cost. @@ -134,7 +134,7 @@ typedef void(^YYWebImageProgressBlock)(NSInteger receivedSize, NSInteger expecte image = [image yy_imageByRoundCornerRadius:5]; return image; } - + @param image The image fetched from url. @param url The image url (remote or local file path). @return The transformed image. @@ -143,12 +143,12 @@ typedef UIImage * _Nullable (^YYWebImageTransformBlock)(UIImage *image, NSURL *u /** The block invoked when image fetch finished or cancelled. - + @param image The image. @param url The image url (remote or local file path). @param from Where the image came from. @param error Error during image fetching. - @param finished If the operation is cancelled, this value is NO, otherwise YES. + @param stage If the operation is cancelled, this value is NO, otherwise YES. */ typedef void (^YYWebImageCompletionBlock)(UIImage * _Nullable image, NSURL *url, @@ -166,14 +166,14 @@ typedef void (^YYWebImageCompletionBlock)(UIImage * _Nullable image, /** Returns global YYWebImageManager instance. - + @return YYWebImageManager shared instance. */ + (instancetype)sharedManager; /** Creates a manager with an image cache and operation queue. - + @param cache Image cache used by manager (pass nil to avoid image cache). @param queue The operation queue on which image operations are scheduled and run (pass nil to make the new operation start immediately without queue). @@ -187,7 +187,7 @@ typedef void (^YYWebImageCompletionBlock)(UIImage * _Nullable image, /** Creates and returns a new image operation, the operation will start immediately. - + @param url The image url (remote or local file path). @param options The options to control image operation. @param progress Progress block which will be invoked on background thread (pass nil to avoid). @@ -202,7 +202,7 @@ typedef void (^YYWebImageCompletionBlock)(UIImage * _Nullable image, completion:(nullable YYWebImageCompletionBlock)completion; /** - The image cache used by image operation. + The image cache used by image operation. You can set it to nil to avoid image cache. */ @property (nullable, nonatomic, strong) YYImageCache *cache; @@ -210,15 +210,15 @@ typedef void (^YYWebImageCompletionBlock)(UIImage * _Nullable image, /** The operation queue on which image operations are scheduled and run. You can set it to nil to make the new operation start immediately without queue. - - You can use this queue to control maximum number of concurrent operations, to obtain + + You can use this queue to control maximum number of concurrent operations, to obtain the status of the current operations, or to cancel all operations in this manager. */ @property (nullable, nonatomic, strong) NSOperationQueue *queue; /** The shared transform block to process image. Default is nil. - + When called `requestImageWithURL:options:progress:transform:completion` and the `transform` is nil, this block will be used. */ @@ -247,21 +247,21 @@ typedef void (^YYWebImageCompletionBlock)(UIImage * _Nullable image, /** A block which will be invoked for each image HTTP request to do additional HTTP header process. Default is nil. - + Use this block to add or remove HTTP header field for a specified URL. */ @property (nullable, nonatomic, copy) NSDictionary *(^headersFilter)(NSURL *url, NSDictionary * _Nullable header); /** A block which will be invoked for each image operation. Default is nil. - + Use this block to provide a custom image cache key for a specified URL. */ @property (nullable, nonatomic, copy) NSString *(^cacheKeyFilter)(NSURL *url); /** Returns the HTTP headers for a specified URL. - + @param url A specified URL. @return HTTP headers. */ @@ -269,7 +269,7 @@ typedef void (^YYWebImageCompletionBlock)(UIImage * _Nullable image, /** Returns the cache key for a specified URL. - + @param url A specified URL @return Cache key used in YYImageCache. */ @@ -280,9 +280,9 @@ typedef void (^YYWebImageCompletionBlock)(UIImage * _Nullable image, Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. - + This method is thread safe. - + This method has no effect in App Extension. */ + (void)incrementNetworkActivityCount; @@ -291,18 +291,18 @@ typedef void (^YYWebImageCompletionBlock)(UIImage * _Nullable image, Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. - + This method is thread safe. - + This method has no effect in App Extension. */ + (void)decrementNetworkActivityCount; /** Get current number of active network requests. - + This method is thread safe. - + This method has no effect in App Extension. */ + (NSInteger)currentNetworkActivityCount;