How can I generate a random alphanumeric string in Swift?
Swift 2.2 Version
// based on https://gist.github.com/samuel-mellert/20b3c99dec168255a046
// which is based on https://gist.github.com/szhernovoy/276e69eb90a0de84dd90
// Updated to work on Swift 2.2
func randomString(length: Int) -> String {
let charactersString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
let charactersArray : [Character] = Array(charactersString.characters)
var string = ""
for _ in 0..
Basically call this method that will generate a random string the length of the integer handed to the function. To change the possible characters just edit the charactersString string. Supports unicode characters too.
https://gist.github.com/gingofthesouth/54bea667b28a815b2fe33a4da986e327