Fondation
具有CharacterSet
结构(桥接到NSCharacterSet),用于管理字符集,例如,在处理Formatter
实例时。令人惊讶的是,CharacterSet不是Set,尽管功能和目的是完全相同的。不幸的是,CharacterSet不是Collection以太,所以现在我不知道如何检索其元素。
// We can initialize with String
let wrongCharacterSet = CharacterSet(charactersIn: "0123456789").inverted
// but how can we get the characters back ?
var chSet = CharacterSet.decimalDigits
let chString = String(chSet) // doesn't work
let chS = Set(chSet) // doesn't work
let chArr = Array(chSet) // doesn't work