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

comments error #159

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
92 changes: 46 additions & 46 deletions YYWebImage/YYWebImageManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,109 +23,109 @@ 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,
};

/// 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,
};


/**
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).
*/
typedef void(^YYWebImageProgressBlock)(NSInteger receivedSize, NSInteger expectedSize);

/**
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.
Expand All @@ -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.
Expand All @@ -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,
Expand All @@ -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).
Expand All @@ -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).
Expand All @@ -202,23 +202,23 @@ 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;

/**
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.
*/
Expand Down Expand Up @@ -247,29 +247,29 @@ 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<NSString *, NSString *> *(^headersFilter)(NSURL *url, NSDictionary<NSString *, NSString *> * _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.
*/
- (nullable NSDictionary<NSString *, NSString *> *)headersForURL:(NSURL *)url;

/**
Returns the cache key for a specified URL.

@param url A specified URL
@return Cache key used in YYImageCache.
*/
Expand All @@ -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;
Expand All @@ -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;
Expand Down