Swift: Initialising a 2D Array

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))
        tiles = tilesArray      

This works, though it feels a little messy... I'll have to come back and look at this again.

Xcode 7 and Swift 2: Unit Testing (again)

Some follow up from creating a new project and adding tests.

This turned out to be important...

This turned out to be important...

I hadn't really noticed in the last one but I hadn't added the new classes to the test target, as I would under Obj-C. In Swift 2 there's a new @testable keyword. I found it blogged by Natasha the Robot when I started looking to find out why I wasn't seeing any code coverage showing up for my classes.

Then I started wondering why I was getting Undefined Symbol errors. I could resolve them by including the classes, but then I wouldn't get coverage and everything I saw on @testable assured me I didn't need to include them. Finally, I remembered I'd been getting a bit click happy earlier. I'd disabled Allow testing Host Application APIs.

One checkbox later and I'm a happy camper...

Okay, not a lot done tonight but I feel like a few pieces fell into place.

Xcode Plugins

Install the Alcatraz (http://alcatraz.io) package manager to get these.  

Shows the whole error/warning in the issue navigator instead of a single line.

Allows you to filter the console by a regular expression. 

Add imports from anywhere in the code base - press Cmd+Ctrl+P to pop up a window which has autocompletion for your headers. 

Fill in a quick documentation template.

Additional refactoring tools. Still not as full-featured as some IDEs but it's a case where every little helps.