swiftios remove all whitespace code example
Example 1: how to get rid of excess space in swift
let str = " Taylor Swift "
let trimmed = str.trimmingCharacters(in: .whitespacesAndNewlines) // prints "Taylor Swift"
Example 2: swift remove space from string
let freedSpaceString = str.filter {!$0.isWhitespace}