Value of type 'String' has no member 'stringByTrimmingCharactersInSet'

前端 未结 4 681
無奈伤痛
無奈伤痛 2020-12-11 00:12

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

4条回答
  •  萌比男神i
    2020-12-11 00:51

    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.

提交回复
热议问题