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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With