From 093193c67bfa2409af93e618a48e3208d63106a5 Mon Sep 17 00:00:00 2001 From: ibireme Date: Sun, 6 Aug 2017 22:57:49 +0800 Subject: [PATCH] Fix Xcode warnings --- YYWebImage/Image/YYAnimatedImageView.m | 5 ++--- YYWebImage/Image/YYImage.m | 4 ++++ YYWebImage/Image/YYImageCoder.h | 2 +- YYWebImage/YYWebImageOperation.m | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/YYWebImage/Image/YYAnimatedImageView.m b/YYWebImage/Image/YYAnimatedImageView.m index 5f2bcb4..07ee652 100644 --- a/YYWebImage/Image/YYAnimatedImageView.m +++ b/YYWebImage/Image/YYAnimatedImageView.m @@ -124,7 +124,6 @@ @interface YYAnimatedImageView() { @package UIImage *_curAnimatedImage; - dispatch_once_t _onceToken; dispatch_semaphore_t _lock; ///< lock for _buffer NSOperationQueue *_requestQueue; ///< image request queue, serial @@ -231,7 +230,7 @@ - (instancetype)initWithImage:(UIImage *)image highlightedImage:(UIImage *)highl // init the animated params. - (void)resetAnimated { - dispatch_once(&_onceToken, ^{ + if (!_link) { _lock = dispatch_semaphore_create(1); _buffer = [NSMutableDictionary new]; _requestQueue = [[NSOperationQueue alloc] init]; @@ -244,7 +243,7 @@ - (void)resetAnimated { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil]; - }); + } [_requestQueue cancelAllOperations]; LOCK( diff --git a/YYWebImage/Image/YYImage.m b/YYWebImage/Image/YYImage.m index aaea939..9fa7efc 100644 --- a/YYWebImage/Image/YYImage.m +++ b/YYWebImage/Image/YYImage.m @@ -212,6 +212,10 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { } } ++ (BOOL)supportsSecureCoding { + return YES; +} + #pragma mark - protocol YYAnimatedImage - (NSUInteger)animatedImageFrameCount { diff --git a/YYWebImage/Image/YYImageCoder.h b/YYWebImage/Image/YYImageCoder.h index 293a45b..31299e7 100644 --- a/YYWebImage/Image/YYImageCoder.h +++ b/YYWebImage/Image/YYImageCoder.h @@ -264,7 +264,7 @@ typedef NS_ENUM(NSUInteger, YYImageBlendOperation) { /** Add an image from a file path to encoder. - @param path Image file path. + @param path Image file path. @param duration Image duration for animation. Pass 0 to ignore this parameter. */ - (void)addImageWithFile:(NSString *)path duration:(NSTimeInterval)duration; diff --git a/YYWebImage/YYWebImageOperation.m b/YYWebImage/YYWebImageOperation.m index b490ecb..30ac1eb 100644 --- a/YYWebImage/YYWebImageOperation.m +++ b/YYWebImage/YYWebImageOperation.m @@ -368,7 +368,7 @@ - (void)_startRequest:(id)object { NSArray *keys = @[NSURLFileSizeKey]; NSDictionary *attr = [_request.URL resourceValuesForKeys:keys error:nil]; NSNumber *fileSize = attr[NSURLFileSizeKey]; - _expectedSize = fileSize ? fileSize.unsignedIntegerValue : -1; + _expectedSize = (fileSize != nil) ? fileSize.unsignedIntegerValue : -1; } // request image from web