ArraySlice index out of range in Swift

后端 未结 2 1961
说谎
说谎 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条回答
  •  梦毁少年i
    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)")
            }
        }
    }
    

提交回复
热议问题