删除前导和尾随空格:
原文链接:https://www.f2er.com/swift/321393.htmllet trimmedString = string.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
Swift 3.0:
let trimmedString = string.trimmingCharacters(in: .whitespaces)