小编Kum*_*ddy的帖子

如何在String Swift4中交换两个字符?

在Swift4中,String是Collections. 您将不再在字符串上使用characters属性.

func swapCharacters(input:String,index1:Int,index2:Int)-> String { // logic to swap }

let input = "ABCDEFGH"
Run Code Online (Sandbox Code Playgroud)

如果我用(输入,3,8)调用该函数,那么输出应该是

输出: ABC H EFG D.

注意:在Swift4中,字符串是集合.

string ios swift4

3
推荐指数
1
解决办法
1679
查看次数

标签 统计

ios ×1

string ×1

swift4 ×1