Merge pull request #2577 from zhongwuzw/fix_memory_cost

Fix memory cost override for SDAnimatedImage
This commit is contained in:
DreamPiggy 2019-01-08 11:27:15 +08:00 committed by GitHub
commit ac1dd066cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View File

@ -429,13 +429,9 @@ static NSArray *SDBundlePreferredScales() {
@end @end
@interface SDAnimatedImage (MemoryCacheCost)
@end
@implementation SDAnimatedImage (MemoryCacheCost) @implementation SDAnimatedImage (MemoryCacheCost)
- (NSUInteger)sd_imageMemoryCost { - (NSUInteger)sd_memoryCost {
NSNumber *value = objc_getAssociatedObject(self, @selector(sd_memoryCost)); NSNumber *value = objc_getAssociatedObject(self, @selector(sd_memoryCost));
if (value != nil) { if (value != nil) {
return value.unsignedIntegerValue; return value.unsignedIntegerValue;

View File

@ -16,8 +16,8 @@
For `UIImage`, this method return the single frame bytes size when `image.images` is nil for static image. Retuen full frame bytes size when `image.images` is not nil for animated image. For `UIImage`, this method return the single frame bytes size when `image.images` is nil for static image. Retuen full frame bytes size when `image.images` is not nil for animated image.
For `NSImage`, this method return the single frame bytes size because `NSImage` does not store all frames in memory. For `NSImage`, this method return the single frame bytes size because `NSImage` does not store all frames in memory.
@note Note that because of the limitations of categories this property can get out of sync if you create another instance with CGImage or other methods. @note Note that because of the limitations of category this property can get out of sync if you create another instance with CGImage or other methods.
@note For custom animated class conforms to `SDAnimatedImage`, you can override this getter method in your subclass to return a more proper value instead, which representing the current frames' total bytes. @note For custom animated class conforms to `SDAnimatedImage`, you can override this getter method in your subclass to return a more proper value instead, which representing the current frame's total bytes.
*/ */
@property (assign, nonatomic) NSUInteger sd_memoryCost; @property (assign, nonatomic) NSUInteger sd_memoryCost;