I'm trying to find a way that I can turn any string into a generated, deterministic number.
That is...
- Each time that the same string is used it will create the same number.
- Different strings will (probably) create different numbers.
For instance, you could add the letter indices in the alphabet for each letter in the string.
Of course, this wouldn't work for strings in languages that don't use the same alphabet.
There must be a better way to get something like that to work though?
NSObject has a method called "hash" that will do this for you: NSObject hash
in ObjectiveC:
in Swift: