【问题标题】:Swift 2.2 - Value of type 'String' has no member 'contains' [duplicate]Swift 2.2 - 'String' 类型的值没有成员'contains' [重复]
【发布时间】:2016-09-23 00:41:58
【问题描述】:

我正在使用 swift 2.2 并收到错误 Value of type 'String' has no member 'contains',这与 swift 2.1 中的相同。如果包含方法在 swift 2.2 中被弃用或删除,任何人都可以帮忙。

代码

var another = "Test"
another.contains("we")

错误:

“字符串”类型的值没有成员“包含”

【问题讨论】:

标签: swift


【解决方案1】:

用途:

another.containsString("we")

你会有用的:

import Foundation

containsString的代码中

【讨论】:

  • IIRC import Cocoa 已经导入 Foundation 所以你不需要添加它。
猜你喜欢
  • 1970-01-01
  • 2017-01-01
  • 1970-01-01
  • 2016-05-27
  • 2020-01-01
  • 1970-01-01
  • 2016-10-07
  • 2016-12-03
  • 2019-08-21
相关资源
最近更新 更多