gpt4 book ai didi

XCode 7 join 已弃用

转载 作者:行者123 更新时间:2023-11-30 14:05:17 26 4
gpt4 key购买 nike

我刚刚下载了 XCode 7 GM 种子。它提示 String 上的 join 方法。如何使用 joinWithSeparator 代替 join?

//1            
// Create an `NSCharacterSet` set which includes everything *but* the digits
let inverseSet = NSCharacterSet(charactersInString:"0123456789").invertedSet

//2
// At every character in this "inverseSet" contained in the string,
// split the string up into components which exclude the characters
// in this inverse set
let components = string.componentsSeparatedByCharactersInSet(inverseSet)

//3
// Rejoin these components
let filtered = "".join(components)

最佳答案

在我弄清楚之后不久,以防您遇到同样的问题。

将第三步替换为下面的行

let Filtered = Components.join With Separator("")

关于XCode 7 join 已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32509714/

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