Basic way
let str = "001|apple|red|002|banana|yellow|003|grapes|purple"
let components = str.components(separatedBy: "|")
let chunkSize = 3
let loopCount = components.count/chunkSize
var packages: [Array] = []
for index in 0..
Output:
[["001", "apple", "red"], ["002", "banana", "yellow"], ["003", "grapes", "purple"]]