Skip to content

Conversation

dreampiggy
Copy link
Contributor

@dreampiggy dreampiggy commented Jan 19, 2018

New Pull Request Checklist

  • I have read and understood the CONTRIBUTING guide

  • I have read the Documentation

  • I have searched for a similar pull request in the project and found none

  • I have updated this branch with the latest master to avoid conflicts (via merge from master or rebase)

  • I have added the required tests to prove the fix/feature I am adding

  • I have updated the documentation (if necessary)

  • I have run the tests and they pass

  • I have run the lint and it passes (pod lib lint)

This merge request fixes / reffers to the following issues: ...

Pull Request Description

This PR add a WebCache category for NSButton on macOS.

The NSButton's design is quite different from UIButton, which based on its NSButtonCell and the image for rendering is based on by two properties called state and type. See SettingButtonImage

In fact, this means there is not a key-value pair for [UIControlState : UIImage] like in UIKit. So if we use #define NSButton UIButton will cause many issue(For example, the forState arg is totally unused for NSButton). So we'd better seperate to create a new category instead.

Thanks to that UIView+WebCache and now we just need to copy-paste the interface and write two lines code, a new WebCache view category can be done easily without touching any Core API.

I update the macOS demo to provide a little button to clear the cache. That works great :)

@codecov-io
Copy link

codecov-io commented Jan 20, 2018

Codecov Report

Merging #2183 into master will increase coverage by 0.02%.
The diff coverage is 47.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2183      +/-   ##
==========================================
+ Coverage    78.7%   78.72%   +0.02%     
==========================================
  Files          36       36              
  Lines        3620     3624       +4     
  Branches      322      322              
==========================================
+ Hits         2849     2853       +4     
  Misses        749      749              
  Partials       22       22
Impacted Files Coverage Δ
SDWebImage/UIButton+WebCache.m 55% <47.36%> (+2.36%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9be6ba4...bccdd2a. Read the comment docs.

@skyline75489
Copy link
Member

This is great. But I'm just curious does anyone really need this feature right now? I'm not a AppKit guy myself.

@dreampiggy
Copy link
Contributor Author

dreampiggy commented Jan 22, 2018

@skyline75489 Actually we have some macOS users. I introduce this because this is easy to integrate and have no bad effect on current Core API (Or I'll not consider to change). I think this can be useful unless you receive from the feature request from user. I'm also considering a better way in the future to support CALayer+WebCache in #1511 (But this maybe a big change to our current design and maybe not add).

Many feature maybe we do not use, but since SD become more porpular cross the platform(iOS/macOS/tvOS/watchOS). I think we should always provide some convenient API for the specify platform instead of just focus on iOS.

@dreampiggy dreampiggy force-pushed the feature_nsbutton_webcache branch from 8f0dcf1 to 7996b0d Compare January 25, 2018 08:45
Copy link
Contributor

@mythodeia mythodeia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though i am not an AppKit coder myself the logic behind this PR valid.

- (SDStateImageURLDictionary *)imageURLStorage {
#pragma mark - Private

- (SDStateImageURLDictionary *)sd_imageURLStorage {
Copy link
Contributor Author

@dreampiggy dreampiggy Jan 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this to sd_imageURLStorage because write any category method is actually in the class method list during runtime. So this may cause name conflict. Seems not current, but have this possibility :)

@dreampiggy dreampiggy merged commit 3a63a68 into SDWebImage:master Jan 26, 2018
@dreampiggy dreampiggy deleted the feature_nsbutton_webcache branch January 26, 2018 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants