Skip to content

Instantly share code, notes, and snippets.

@bananafish911
Last active October 15, 2016 09:17
Show Gist options
  • Save bananafish911/a6a2a62e2ebef7f42eb07938e3f672c7 to your computer and use it in GitHub Desktop.
Save bananafish911/a6a2a62e2ebef7f42eb07938e3f672c7 to your computer and use it in GitHub Desktop.
extension String {
///For placeholders
static func randomAlphaNumericString(length: Int) -> String {
let charactersString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
let charactersArray : [Character] = Array(charactersString.characters)
var string = ""
for _ in 0..<length {
string.append(charactersArray[Int(arc4random()) % charactersArray.count])
}
return string
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment