gpt4 book ai didi

swift - replacingOccurrences 出现字符串错误

转载 作者:可可西里 更新时间:2023-11-01 02:05:10 26 4
gpt4 key购买 nike

对于以下 Swift 3 代码:

var password = "Mary had a little lamp"
var newPassword = password.replacingOccurrences(of: "a", with: "A")

我在调用 replacingOccurrences 时遇到此错误:

value of type 'String' has no member 'replacingOccurrences'

最佳答案

试试这个,在 swift3 中工作

var newPassword = password.replacingOccurrences(of: "a", with: "A", options: NSString.CompareOptions.literal, range: nil)

关于swift - replacingOccurrences 出现字符串错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43445165/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com