Remove last character from string. Swift language

前端 未结 22 1746
Happy的楠姐
Happy的楠姐 2020-11-30 17:33

How can I remove last character from String variable using Swift? Can\'t find it in documentation.

Here is full example:

var expression = \"45+22\"
e         


        
22条回答
  •  孤城傲影
    2020-11-30 17:58

    complimentary to the above code I wanted to remove the beginning of the string and could not find a reference anywhere. Here is how I did it:

    var mac = peripheral.identifier.description
    let range = mac.startIndex..

    This trims 17 characters from the beginning of the string (he total string length is 67 we advance -50 from the end and there you have it.

提交回复
热议问题