After converting my project to swift 3, I get the following Value of type \'String\' has no member \'stringByTrimmingCharactersInSet\'
error on the first line w
The new syntax is like this:
var cString = hex.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).uppercased()
As a suggestion, you don't need to specify that cString
is a String, as this is assumed with the value you are assigning to it.
Read the Swift 3 documentation; the new Swift 3 API is:
func trimmingCharacters(in set: CharacterSet) -> String
https://developer.apple.com/reference/swift/string/1643030-trimmingcharacters
You can try this as well.
let trimmedString = hex.trimmingCharacters(in: CharacterSet.whitespaces)
And for an Int and Float how can I code it ?
private var currentTotal_passengers: Int = 0 {
didSet {
currentTotal_passengers = currentTotal_passengers.trimmingCharacters(in: CharacterSet .whitespacesAndNewlines)
}
}