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
Fi?le*/ Name
File_Name
Solution in Swift 4
extension String { var sanitizedFileName: String { return components(separatedBy: .init(charactersIn: "/\:\?%*|\"<>")).joined() } }
Usage:
"https://myurl.com".sanitizedFileName // = httpsmyurl.com