为什么一些Swift标准库函数在操场上无法识别?

时间:2015-09-28 02:04:04

标签: xcode swift swift2 swift-playground

有一个名为Clicked的函数,它应该是Swift 中的标准库函数(该函数出现在第160页的当前Swift 2.0更新版本的' The Swift中编程语言')

那么,下面的代码不应该起作用吗?

Playground

1 个答案:

答案 0 :(得分:4)

使用Swift 2.0,不再有countElements(...)方法。请改用stringA.characters.countcharacters从字符串返回一个字符数组,count返回字符数组中的项目数。

文档:https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/StringsAndCharacters.html#//apple_ref/doc/uid/TP40014097-CH7-ID297

相关问题