Skip to content
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

Switched hash for an implementation of MD5 cache to great unique URL keys #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AdamSwinden
Copy link

I ran into a problem where the inline static NSString* keyForURL(NSURL* url, NSString* style) method was not returning a unique URL key for my images.

I noticed it when 3 different images with different URLs in one app all produced the same URL key using hash therefore the wrong image was loaded from the cache.

I have added an NSString category (NSString+MD5) with a single method, - (NSString *)md5Hash; that returns a MD5 hash of a string. I have swapped the origin use for hash in EGOImageLoader.m for this new method.

I've done some testing and it seems to have solved my problem.

I haven't included any credit in the header of the NSString category as I found it on Stack Overflow where no credit was given.

@btjones
Copy link

btjones commented Sep 20, 2011

I had this issue too with some long image URLs that contained a lot of query string parameters. Using the md5 hash instead does fix the problem. Thanks for the fix Adam! Hope it's merged into the enormego repo so others can avoid this.

@hSATAC
Copy link

hSATAC commented Jul 26, 2012

it solved my problem thx! but I use %@ instead of %u

@hwaxxer
Copy link

hwaxxer commented Jan 28, 2013

Would be great if this was merged. The problem with using -hash on NSString is demonstrated here: https://gist.github.com/3413755
Two strings have the same hash when the first, center, and last 32 chars are identical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants