A category that modifies an existing mutable String:
extension String { mutating func replace(originalString:String, withString newString:String) { let replacedString = self.stringByReplacingOccurrencesOfString(originalString, withString: newString, options: nil, range: nil) self = replacedString } } Use:
name.replace(" ", withString: "+")