【问题标题】:Swift find() method throwing errorSwift find() 方法抛出错误
【发布时间】:2015-12-24 19:40:31
【问题描述】:

当我今天打开我的应用程序时,Xcode 询问我是否想更新一些语法。我按照更新提示进行操作,毕竟我的应用程序现在在“查找”方法之一上出现此错误。我已经为此挠头了大约一个小时。关于可能发生的变化有什么建议吗?

【问题讨论】:

  • 也许你应该发布有问题的代码,你得到的错误等等。
  • 您将 Xcode 更新到 7.x
  • 其实错误信息告诉你该怎么做
  • @vadian 喜欢这样吗? if let index = indexOf(playlistArray, playlistImageView)
  • method calling on object 表示object.method(),看我的回答

标签: xcode swift xcode6 segue


【解决方案1】:

As discussed here,Swift 2.0 删除了 find 方法并将其替换为 indexOf(如 Xcode 给出的错误所示)。

您可以按如下方式修复您的代码:

if let index = playlistArray.indexOf(playlistImageView)

【讨论】:

    【解决方案2】:

    仔细阅读错误信息。它说

    find(haystack, needle)不可用,请致电haystack.indexOf(needle)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-31
      • 2023-03-11
      • 2016-02-19
      • 1970-01-01
      • 2015-03-08
      • 2016-04-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多