-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Keep a reference to the image URL #560
Conversation
Good idea. Could you please extend it to all supported category please? Additionally, the direct change of the |
Yes. I will extend it to the other categories somewhere this week. How would you suggest I detect the change of the image property? Since this is a category I don't think it's a good idea to implement the image property since that will override the default implementation. The only option I think is to use method swizzling which a lot of developers still consider dangerous. I personally don't have a big issue with it because, as the author points out, it can be useful when used appropriately. Before I go down this road let me know if this is an acceptable solution. |
I'm not very confortable with method swizzling in this kind of project. KVO could work but maybe it's too much of a burden for such edge case. What do you think? |
I think KVO has the same problem as simple overriding the The only solution that I can think of that doesn't involve method swizzling is subclassing |
Ok, that's not really an option in term of ease of use. I guess we'll have to live with the fact that you can get |
@rs Done. Let me know what you think. |
Sounds good! Last thing before the merge, could you please add returns before all open brackets in order to comply with the project's coding style? |
regarding KVO: you can create a separate class that acts as the observer and let the imageView hold a reference to that object (associated object). In this case it doesn't matter, whether the default implementation of UIImageView implements observeValueForKeyPath:ofObject:change:context: or not. |
@rs What do you think we should do over here? Update this pull request? It still relies on dynamically adding properties to the classes (a practice I don't think we should encourage). |
Why not? |
@klaaspieter could you rebase this on top of master, so it can be merged? |
Done. |
Thanks @klaaspieter. Merging |
Keep a reference to the image URL
Currently it's impossible to verify that the image view is showing the correct image when it's loaded from a URL. This makes it hard to test code that interacts with this category because it's impossible to verify that the correct URL was loaded.
This PR uses associated objects to keep a reference to the set
imageURL
. Before I add this to the other categories I'd like to know if people agree with this approach.