Adopt all the protocol APIs which contains getter value to use property instead, to make the API easy to use or Swift user

This commit is contained in:
DreamPiggy 2018-08-19 12:09:31 +08:00
parent 5a2b9b2c51
commit 8c5db9484b
8 changed files with 19 additions and 21 deletions

View File

@ -43,7 +43,7 @@
/**
Returns a Boolean value indicating whether all animated image frames are already pre-loaded into memory.
*/
- (BOOL)isAllFramesLoaded;
@property (nonatomic, assign, readonly, getter=isAllFramesLoaded) BOOL allFramesLoaded;
@end

View File

@ -85,7 +85,7 @@
@return The total data count.
*/
- (NSInteger)totalCount;
- (NSUInteger)totalCount;
/**
Returns the total size (in bytes) of data in this cache.
@ -93,7 +93,7 @@
@return The total data size in bytes.
*/
- (NSInteger)totalSize;
- (NSUInteger)totalSize;
@end

View File

@ -203,7 +203,7 @@
return [self cachePathForKey:key inPath:self.diskCachePath];
}
- (NSInteger)totalSize {
- (NSUInteger)totalSize {
NSUInteger size = 0;
NSDirectoryEnumerator *fileEnumerator = [self.fileManager enumeratorAtPath:self.diskCachePath];
for (NSString *fileName in fileEnumerator) {
@ -214,7 +214,7 @@
return size;
}
- (NSInteger)totalCount {
- (NSUInteger)totalCount {
NSUInteger count = 0;
NSDirectoryEnumerator *fileEnumerator = [self.fileManager enumeratorAtPath:self.diskCachePath];
count = fileEnumerator.allObjects.count;

View File

@ -164,7 +164,7 @@ FOUNDATION_EXPORT SDImageCoderOption _Nonnull const SDImageCoderWebImageContext;
@return The animated image data
*/
- (nullable NSData *)animatedImageData;
@property (nonatomic, copy, readonly, nullable) NSData *animatedImageData;
/**
Total animated frame count.
@ -172,13 +172,13 @@ FOUNDATION_EXPORT SDImageCoderOption _Nonnull const SDImageCoderWebImageContext;
@return Total animated frame count.
*/
- (NSUInteger)animatedImageFrameCount;
@property (nonatomic, assign, readonly) NSUInteger animatedImageFrameCount;
/**
Animation loop count, 0 means infinite looping.
@return Animation loop count
*/
- (NSUInteger)animatedImageLoopCount;
@property (nonatomic, assign, readonly) NSUInteger animatedImageLoopCount;
/**
Returns the frame image from a specified index.
@note The index maybe randomly if one image was set to different imageViews, keep it re-entrant. (It's not recommend to store the images into array because it's memory consuming)

View File

@ -32,7 +32,7 @@ FOUNDATION_EXPORT NSString * _Nullable SDTransformedKeyForKey(NSString * _Nullab
@return The cache key to appended after the original cache key. Should not be nil.
*/
- (nonnull NSString *)transformerKey;
@property (nonatomic, copy, readonly, nonnull) NSString *transformerKey;
/**
Transform the image to another image.

View File

@ -38,15 +38,13 @@ FOUNDATION_EXPORT NSString * _Nonnull const SDWebImageDownloadFinishNotification
- (BOOL)cancel:(nullable id)token;
- (nullable NSURLRequest *)request;
- (nullable NSURLResponse *)response;
@property (strong, nonatomic, readonly, nullable) NSURLRequest *request;
@property (strong, nonatomic, readonly, nullable) NSURLResponse *response;
@optional
- (nullable NSURLSessionTask *)dataTask;
- (nullable NSURLCredential *)credential;
- (void)setCredential:(nullable NSURLCredential *)credential;
- (double)minimumProgressInterval;
- (void)setMinimumProgressInterval:(double)minimumProgressInterval;
@property (strong, nonatomic, readonly, nullable) NSURLSessionTask *dataTask;
@property (strong, nonatomic, nullable) NSURLCredential *credential;
@property (assign, nonatomic) double minimumProgressInterval;
@end
@ -61,7 +59,7 @@ FOUNDATION_EXPORT NSString * _Nonnull const SDWebImageDownloadFinishNotification
/**
* The response returned by the operation's task.
*/
@property (strong, nonatomic, nullable, readonly) NSURLResponse *response;
@property (strong, nonatomic, readonly, nullable) NSURLResponse *response;
/**
* The operation's task
@ -73,7 +71,7 @@ FOUNDATION_EXPORT NSString * _Nonnull const SDWebImageDownloadFinishNotification
*
* This will be overridden by any shared credentials that exist for the username or password of the request URL, if present.
*/
@property (nonatomic, strong, nullable) NSURLCredential *credential;
@property (strong, nonatomic, nullable) NSURLCredential *credential;
/**
* The minimum interval about progress percent during network downloading. Which means the next progress callback and current progress callback's progress percent difference should be larger or equal to this value. However, the final finish download progress callback does not get effected.

View File

@ -20,7 +20,7 @@
@return The indicator view
*/
- (nonnull UIView *)indicatorView;
@property (nonatomic, strong, readonly, nonnull) UIView *indicatorView;
/**
Start the animating for indicator.
*/

View File

@ -91,11 +91,11 @@
[self.fileManager createFileAtPath:[self cachePathForKey:key] contents:data attributes:nil];
}
- (NSInteger)totalCount {
- (NSUInteger)totalCount {
return [self.fileManager contentsOfDirectoryAtPath:self.cachePath error:nil].count;
}
- (NSInteger)totalSize {
- (NSUInteger)totalSize {
NSUInteger size = 0;
for (NSString *fileName in [self.fileManager enumeratorAtPath:self.cachePath]) {
NSString *filePath = [self.cachePath stringByAppendingPathComponent:fileName];