How to remove multiple spaces in Strings with Swift 2
In Swift 2, join has become joinWithSeparator and you call it on the array. In filter, isEmpty should be called on the current iteration item $0. To replace whitespaces and newline characters with unique space characters as in your question: extension String { func condenseWhitespace() -> String { let components = self.componentsSeparatedByCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()) return components.filter { … Read more