I want to divide Model array into two different arrays by using prefix , postfix
let data = serverResponse.data as! [User]
collectionData = data.prefix(upTo: 10)
tableData = data.suffix(from: 11)
I want to divide Model array into two different arrays by using prefix , postfix
let data = serverResponse.data as! [User]
collectionData = data.prefix(upTo: 10)
tableData = data.suffix(from: 11)
You need to convert the array slices returned by prefix
and suffix
to arrays by calling the initializer of Array
accepting an ArraySlice
.
let data = serverResponse.data as! [User]
collectionData = Array(data.prefix(upTo: 10))
tableData = Array(data.suffix(from: 11))