【问题标题】:Xcode 7.0 beta 4 not detect swift 2.0Xcode 7.0 beta 4 检测不到 swift 2.0
【发布时间】:2015-09-11 11:12:43
【问题描述】:

我已经安装了 Xcode 7.0 beta 4 但是,我认为 Xcode 将能够在我的代码中检测到 swift 2.0 功能

    let array = ["1", "2", "3"]
    let stringRepresentation = array.joinWithSeparator("-")
    print(stringRepresentation)

Xcode 显示错误“'[String]' does not have a member named 'joinWithSeparator'”,如下图所示

当我在终端运行“xcrun swift”时,它也会显示

Welcome to Apple Swift version 2.0 (700.0.47.1 700.0.59.1). Type :help for assistance.
1>  

在这里我被难住了,无法运行 swift 2.0 代码。

【问题讨论】:

    标签: ios xcode swift2


    【解决方案1】:

    joinWithSeparator 出现在 Xcode beta 6 中。

    【讨论】:

      【解决方案2】:

      Swift 2.0 Xcode 7.0 beta 6 以后使用joinWithSeparator() 而不是 join():

      但你可以使用join获得输出

        let array = ["1", "2", "3"]
        let stringRepresentation = "-".join(array)
        print(stringRepresentation)  //output- 1-2-3  
      

      【讨论】:

      • 我正在使用“alamofire”,它使用“joinWithSeparator”,他们说它在 swift 2.0 上运行,我收到错误
      • 是的,但您使用的是 xcode 7.0 beta 4.0 和方法 joinWithSeparator,您可以使用 xcode 7.0 beta 6.0 向前...您可以改用 Join,它肯定会工作
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-28
      • 2015-08-27
      • 2015-06-07
      • 1970-01-01
      • 2015-12-05
      相关资源
      最近更新 更多