ios - 使用未解析的标识符 countElements

标签 ios swift swift2 ios9

let newLength = countElements(textField.text) + countElements(string) - range.length;

当我运行我的应用程序时,它突然显示无法解析的标识符的错误。

最佳答案

您似乎正在尝试在更高版本的 Swift 中使用 Swift 1.0 代码。 countElements 已在 iOS 8.3(使用 Swift 1.2)中删除——您需要登录才能查看 release notes

在 Swift 2.0 中,现在是 str.characters.count

关于ios - 使用未解析的标识符 countElements,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40657016/

相关文章:

ios - 每次运行都需要 MobileServiceSQLiteStore.DefineTable<T> 吗?如果是,为什么?

ios 8 Swift - 带有嵌入式 CollectionView 的 TableView

ios - 如何获取具有最高 Int 的变量并检索 String Swift

swift - 如何更改 searchController?.searchBar 的大小和位置?

ios - 从 UIButton 继承时,continueTrackingWithTouch 不起作用

iOS15 otpauth 打开 Apple 密码管理器而不是 Google Auth? iOS 14 运行正常

ios - 为什么UIProgressView不更新?

swift 2.0 : Creating a Collection Type of Objects that conform to a Generic Protocol

ios - Cocoapods + 无法为 'x' 加载底层模块

swift - 如何在 swift 中将井字棋板绘制为 UIView?