We want to remove blank characters at both side of string.
Swift doesn’t has trim() command like Java, we need to create new class like
this.
import Foundation
import UIKit
extension String
{
func trim() ->String
{
returnself.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
}
}
Now whenever want to trim blank characters, we use this.
let nospace=
text.trim()
No comments:
Post a Comment