I have an array that I'm using to create a grid with the use of a collection view. To provide the numberOfItemsInSection in the collectionView I am doing row.count * row.count
to get an 8x8 grid and 64 cells. My problem is that I want to be able to access and manipulate these cells via their rows and columns, not the indexPath.row.
So if I want the 5th cell, instead of getting #4 in IndexPath.row I want to be able to do: row[0][4]. Any suggestions on how to convert IndexPath.row into a 2D array?
var row = [[Int]]()
let column: [Int]
init() {
self.column = [1, 2, 3, 4, 5, 6, 7, 8]
}
func createGrid() {
for _ in 1...8 {
row.append(column)
}
}
the blue squares/cells are the cells that I want the row and columns for