【发布时间】:2015-09-10 18:58:19
【问题描述】:
我刚刚下载了 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)
【问题讨论】: