var numbers = "Hello,Goodbye,Hi,Bye"
var numbersArr = numbers.componentsSeparatedByString(",")
Run Code Online (Sandbox Code Playgroud)
//["Hello"."Goodbye","Hi","Bye"]
以上是我正在尝试做的基本表示.我正在尝试使用componentsSeparatedByString()逗号将字符串拆分为数组,其中数组的每个组件都位于原始字符串的每个逗号之间.
我正在使用IBM Swift Sandbox(抱歉,我在Windows上:)),在Swift 3.0中,我收到此错误消息:
value of type 'String' has no member 'componentsSeparatedByString'
Run Code Online (Sandbox Code Playgroud)
我知道Swift 3相当新,这就是为什么我找不到这个错误的任何其他参考.
Ste*_*ing 98
它看起来像有一个components(separatedBy:)上String:
import Foundation
let words = "apple binary cat delta echo".components(separatedBy: " ")
print(words)
Run Code Online (Sandbox Code Playgroud)
IBM Playground链接:http: //swiftlang.ng.bluemix.net/#/repl/57868332b4e4e9971bf9f4e8
| 归档时间: |
|
| 查看次数: |
32521 次 |
| 最近记录: |