0
myText = "word 1/word 2"
var testVar = split(myText, { $0 == "/"}, maxSplit: Int.max, allowEmptySlices: false)
此代碼工作的一個亞型,但它需要空的空間「單詞1」的時候我用的testvar [0]斯威夫特 - 性格是不串
當我寫空的空間
var testVar = split(myText, { $0 == "/"}, maxSplit: Int.max, allowEmptySlices: false)
我得到一個錯誤:'字符'不是'字符串'的子類型
任何人誰知道如何解決這個問題?
大:)感謝ü:) – 2014-10-29 16:07:02
此外,以供將來參考,'的最後兩個參數split'有默認值,所以你可以離開他們out:'var testVar = split(myText,{$ 0 ==「/」})'' – 2014-10-29 16:11:24