我有一个非常奇怪的错误.一直在学习Swift,并且正在阅读有关在数组中查找对象索引的文档:https://developer.apple.com/reference/swift/array/1689674-index
但是我的Xcode中不存在这种方法.
这是一个例子:
var items : [TaskItem]
items = [TaskItem] ()
let rowitem = TaskItem()
rowitem.text = "helloworld"
items.append(rowitem)
//Attempting to find the index of an object
items.Index(of: rowitem)
Run Code Online (Sandbox Code Playgroud)
//错误 - Xcode无法找到我正在寻找的特定功能
我附上了一个出现的方法的图像,但是无法找到答案,为什么这可能发生在任何地方.
我找不到使用func索引(of :)方法,虽然我知道它存在!
我得到以下编译器错误:
ChecklistViewController.swift:186:26:参数标签'(of:,_ :)'与任何可用的重载都不匹配
ChecklistViewController.swift:186:26:这些部分匹配的参数列表存在'index'的重载:(Int,offsetBy:Int),(Self.Index,offsetBy:Self.IndexDistance)
| 归档时间: |
|
| 查看次数: |
886 次 |
| 最近记录: |