ArraySlice index out of range in Swift

后端 未结 2 1959
说谎
说谎 2021-01-23 12:30

I have data in the following format

[\"DATA1-1\",\"DATA1-2\",\"DATA1-3\",\"DATA1-4\",\"\",\"DATA2-1\",\"DATA2-2\",\"DATA2-3\",\"DATA2-4\",\"\",\"DATA3-1\",\"DATA3-2\",\"

相关标签:
2条回答
  • 2021-01-23 13:02

    The code now works with Swift 2.2

    0 讨论(0)
  • 2021-01-23 13:06

    Try like this:

    func arraySliceFunction(array: [String]) {
        // Slice the master array with all combinations of airways into separate arrays
        // Iterate through the each subArray 
        for subArray in array.split("") {
            // Iterate through each item in subArray
            for item in subArray {
                print("SLICES COMPONENT: \(item)")
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题