0

I have a long NSString like that;

[NSString stringWithFormat:@"st=WVhCd1ZYSnNQV2gwZEhBbE0wRWxNa1lsTWtZMU5UWTBOVGcxTlM1dVpYUnRaWEpoTG1OdmJTVXpRVGd3SlRKR2JXOWlhVzFsY21FbE1rWm5ZV1JuWlhRbE1rWm9iMjFsTG5odGJDWnViVk5wZEdWVmNtdzlhSFIwY0NVelFTVXlSaVV5UmpVMU5qUTFPRFUxTG01bGRHMWxjbUV1WTI5dEpUTkJPREFtYlc5a2RXeGxTV1E5TXpnNU1TWmhjSEJKWkQwMU5UWTBOVGcxTlNadWJWUmxiWEJzWVhSbFBXMXZZbWwwWlcxd2JHRjBaU1p2ZDI1bGNrbGtQWE5sY21oaGRDMXpZWEpwSm1SdmJXRnBiajF1WlhSdFpYSmhMbU52YlNadWJWTnBkR1U5TlRVMk5EVTROVFVtYjNkdVpYSlNiMnhsVkhsd1pUMHhKblpwWlhkbGNsSnZiR1ZVZVhCbFBURW1kbWxsZDJWeVNXUTljMlZ5YUdGMExYTmhjbWtt&max=10"];

It is too long and i should make it shorter. It must me unique with its original string. Any idea?

Thanks;

Mustafa Genç
  • 2,569
  • 19
  • 34
serhats
  • 246
  • 2
  • 7

4 Answers4

2

this blog is a good solution of my question.

http://mobiledevelopertips.com/core-services/create-md5-hash-from-nsstring-nsdata-or-file.html

serhats
  • 246
  • 2
  • 7
1

If you don't want to retrieve the string later, you can hash it with, for example, SHA1 (have a look at Apple's CommonCrypto library).

0

I don't work with iphone or objective c, but this seems like you could use something like a hashmap or a dictionary - value being the shortened string (cache file name), or whatever, and key being your long url. I guess there's some data structure available in objective c/iOS for this purposes...
Also, have a look at this question.
It might not be a good idea to use really long strings for dictionary keys, it's usually the other way around: keys are short, value holds arbitrary data.

Community
  • 1
  • 1
Less
  • 3,047
  • 3
  • 35
  • 46
0

There are some wrapper classes used for shortening URLs like MKBitlyHelper.Using this class you can shorten your url and then use it further.You can get it from here http://blog.mugunthkumar.com/coding/bit-ly-wrapper-objective-c-iphone/

AJS
  • 1,403
  • 12
  • 17