0

I have this file on my iPhone on Documents Directory that weights 200kb exactly. I want that every time when the application is loaded, the app will check if my file that is on the iPhone is smaller than the file that is on the website, if the file on the iPhone smaller, he will download the new file from the web, if he is the same he will not do nothing.

I check the web and stackOverflow for an answer, but couldn't find any.

Thanks in advance.

ytpm
  • 4,962
  • 6
  • 56
  • 113
  • 4
    If you are checking the size to determine whether to update or not, I would suggest using the file's hash (MD5, SHA1) to determine that. It will give you more flexibility in the future and you'll be able to use any file size. – Pepe Apr 02 '12 at 14:23
  • well yes, this is the purpose of the question. I want to determine if to update or not, but I dont have any idea what MD5, SHA1 is. how do I use it? – ytpm Apr 02 '12 at 14:37
  • There you go http://stackoverflow.com/questions/7632145/how-do-i-create-a-hash-of-a-file-on-ios – Pepe Apr 02 '12 at 15:05
  • so what you are telling me is to create for each file unique id and with that I can know if the file is new or not? – ytpm Apr 02 '12 at 15:18
  • No. First calculate the hash of the file you have on disk (call it hash1) and then calculate the hash of the file on the server (let the server do it and send it back to you it's fairly easy in php) then compare the 2 hashes if they are equal then the file hasn't changed. – Pepe Apr 02 '12 at 15:20
  • The link I posted shows you how to calculate the hash of a file on the iOS. – Pepe Apr 02 '12 at 15:20
  • get a screen size and compare with size you need? – Gargo Apr 02 '12 at 15:38
  • Gargo, what did you mean? I want to compare the file on iOS with file on the Website. – ytpm Apr 02 '12 at 15:41
  • 1
    @YossiTsafar You can think of the file's (MD5,SHA1) hash as an unique id. Like idFile = hash(file), idWeb = hash(webFile), if idFile != idWeb, that means the files are different. – fbernardo Apr 02 '12 at 16:25
  • I still don't know how to generate md for a specific file.. how to do it? – ytpm Apr 03 '12 at 13:50

0 Answers0