我在使用count()时遇到了一个奇怪的错误,所以我有以下方法
func count(ch:String)->Int {
let chars = Set(ch)
var fu = removeUnwantaedCharacters(strand, set: chars)
let bli:String = fu
return 0
}
func removeUnwantaedCharacters(text: String, set characterSet: Set<Character>) -> String {
return String(filter(text) { characterSet.contains($0) })
}这个很好用。假设我想要富的长度,然后加上
count(fu)(忘了布莱吧.)
我收到一个错误:
EXC_BAD_ACCESS code=2和错误在removeUnwantedCharacters函数的返回语句中。
这说得通吗?
谢谢你帮忙!
发布于 2015-08-14 07:21:51
Swift已经有了这样一个count函数:
func count<T : _CollectionType>(x: T) -> T.Index.Distance因此,更改您的count函数名,因为它是混乱的编译器。
https://stackoverflow.com/questions/32004219
复制相似问题