user2213271
user2213271

Reputation: 421

check downloaded NSData hash

My app downloads small pictures for different objects, and I save them in phone with a unique fileName. I need to check if the image on server has changed. After I download the big pictures, I make a string with date when it was modified. If the date when it was modified has changed, I download new big picture. But for small pictures I don't want go on the same way. So I want always download the file, and check a hash of the data to see if it has changed. And if data has a different hash - I will download picture.

Can I check if downloaded data like data saved on device? Are this datas will have same hash?

Upvotes: 1

Views: 1423

Answers (1)

Thomas Zoechling
Thomas Zoechling

Reputation: 34253

This Stackoverflow question contains a nice NSData category that uses MD5: https://stackoverflow.com/a/2018626/100848

You could instantiate a NSImage and call the above hash method on it's TIFFRepresentation.

Upvotes: 1

Related Questions