title: Objective-C get tile positions from CCTMXTiledMap (Cocos2d)
body: <p>I am trying to make a simple loop that goes over all the tiles in the CCTMXLayer in the CCTMXTiledMap. All I want to achieve is to print out the position of every single tile, but for the life of me i can't figure out how to loop through the tiles or how to even get access to their container. I am a objective-c newbie, so please be gentle :)</p>
  
  <p>Please halp!</p>
  
  <p>What I have so far:</p>
  
  <pre><code>CGSize mapSize = [_tileMap mapSize];
  CCTMXLayer *backgroundLayer = [_tileMap layerNamed:@"Background"];
  int h = 0;
  int w = 0;
  NSInteger i = 0;
  for(h = 0; h &lt; mapSize.height; h++)
  {
      for(w = 0; w &lt; mapSize.width; w++)
      {
          i = h * mapSize.width + w;
          // I tried the following but none of it worked:
          //CCArray* tiles = [backgroundLayer  children];
          //CCSprite *tile = [backgroundLayer tileAt:tileCoord];
          //CCSprite*tile = [tiles objectAtIndex:i];
          //CCNode* tile = [backgroundLayer children getChildByTag:i];
          CGPoint position = [tile position];
          [_debugHud addTileId:i at:position];
      }
  }
  </code></pre>