I\'m using very tricky fighting methods :) to make a string like Fi?le*/ Name
safe for using as a file name like File_Name
.
I\'m sure there is a cocoa
And of course there's got to be a swift2 guy with an arbitrary hate list (stolen from other answers). That guy is me:
func sanitizedString(string : String) -> String {
// put anything you dislike in that set ;-)
let invalidFsChars = NSCharacterSet(charactersInString: "/* <>?%|")
let components = string.componentsSeparatedByCharactersInSet(invalidFsChars)
return components.joinWithSeparator("")
}