The most typical way to create a new character set is using
+ characterSetWithCharactersInString, giving a
NSString with all the characters of the set.
Adding some characters to an existing set can be achieved using:
let characterSet = NSMutableCharacterSet() //create an empty mutable set characterSet.formUnionWithCharacterSet(NSCharacterSet.URLQueryAllowedCharacterSet()) characterSet.addCharactersInString("?&")
For URL encoding, also note Objective-C url encoding