Sorry, I think you didn't doing right.
First, you didn't detect and set layer->_tiles[tilesAmount - 1] to 0  at Layer parse end, so When I don't have tiles[tilesAmount - 1] data in TMX, we get a wrong data.
Second, if I have tiles[tilesAmount - 2] data and don't have tiles[tilesAmount - 1] data in TMX,  we have no way to find out whether the tiles[tilesAmount - 1] is a real data or just a count.
So if you want do it my way, I think you'd better understand my previous comment and think carefully.