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
Name collisions in UIImageView category #350
Comments
|
I agree with @matej because it is real problem (not only in this repo) naming new variables, types, methods without unique prefix. I don't understand what do you mean when talk about backward compatibility. If you change the name of methods in new version (for example), then other programmers should change those code in 10-20 places. It is not so hard work, but it will fix the problem and all subsequent. @matej, you should copy your post to AFNetworking :) |
In order not to break backward compatibility, you could mark these methods as deprecated in the interface and implement them dynamically with +[NSObject resolveInstanceMethod:] for example. |
I just want to add that I ran into this problem as well and quickly made some changes on this fork: https://github.com/PaulWoodIII/SDWebImage I'm not asking for a merge here but maybe it'll help someone else interested in this issue. @0xced if you could share some code on how to use resolveInstanceMethod I could add that in as well. |
Hi all, For anyone looking to use both SDWebImage and AFNetworking as-is, here's my caveman solution to discourage use of the colliding methods: https://gist.github.com/sibljon/5957892 It's obviously not future proof, and is prone to breaking if the implementation of these methods changes in AFNetworking or SDWebImage. It's far from an ideal solution. In other words, at your own risk! Jon |
👍 |
In addition to the already suggested transition options, another way could be to use conditional compilation and give those of us who want prefixes the ability to turn on prefixing by defining a preprocessor macro (ex. |
An update to this thread:
This means that developers (like @matej, myself, ...) can specify just the AFNetworking core subspec i.e.
Given those, I don't see a solid solution, so I would just leave things as they are. |
Good news guys. This was fixed in #770, all those category methods now have a |
Hi Olivier,
I've noticed that UIImageView+WebCache collides with some methods in UIImageView+AFNetworking (e.g., setImageWithURL: and setImageWithURL:).
I think it's pretty likely that those two libraries are used in the same project, at least that's true fro several of my projects, so it would make sense to do something about this and prevent undefined runtime behavior. Prefixes are the most robust solution, although simply renaming the method name to something slightly different would also probably work fine for now, without sacrificing legibility.
It would also be interesting to hear what @mattt has to say about this.
My solution for this problem is to simply avoid the colliding methods and use one of the long-form methods that differs from the ones defined in the AFNetworking category. This might me a well enough solution for me personally, but I'm pretty sure that sooner or later someone is going to run into some problems with this.
The text was updated successfully, but these errors were encountered: