I have a struct called Tile, which has (for now) a position defined as a tuple:
struct Tile { let pos: (Int, Int) }
And a class called Board, which has a 2D array of Tile objects:
class Board { let tiles: [[Tile]] init() { var tilesArray = [[Tile]]() for row in 0..<Board.rows { var rowTiles = [Tile]() for column in 0..<Board.columns { let tile = Tile(pos:(column, row)) rowTiles.append(tile) } tilesArray.append(rowTiles) } tiles = tilesArray } }
This works, though it feels a little messy... I'll have to come back and look at this again.