title: How to get file path in iPhone app
body: <p>I have a problem accessing my files in my app.</p>
  
  <p>I am currently using </p>
  
  <pre><code>//Directly from TileMap example from WWDC2010
  NSString *tileDirectory = [[[NSBundle mainBundle] resourcePath] 
                             stringByAppendingPathComponent:@"Tiles"];
  </code></pre>
  
  <p>to access my tiles for my <code>MKOverlay</code>. This gives me this directory</p>
  
  <blockquote>
    <p>/Users/xxxx/Library/Application Support/iPhone Simulator/4.2/Applications/9D62025C-C53B-472C-8309-xxxx/xxxx.app/Tiles</p>
  </blockquote>
  
  <p><em>The x's is only for privacy reasons</em></p>
  
  <p>I have my tiles in a folder called <code>Tiles</code> in the root of my application which is in Xcode in a group called <code>Tiles</code> which is in directly in the <code>Resources</code> group.</p>
  
  <p>When I run my app, I get a simple error saying that it could not find my tiles at the generated directory (the one quote above) If I replace that piece of code and make it:</p>
  
  <pre><code>NSString *tileDirectory = @"/Users/xxxx/Documents/xxxx/Tiles";
  </code></pre>
  
  <p>Then my app works fine. This is obviously because it finds my tiles in its direct location on my Mac. This is fine for testing, but I need it to work on my iPhone/iPad.</p>
  
  <p>This problem might be occurring due to:</p>
  
  <ul>
  <li>The generated directory is incorrect.</li>
  <li>The tile images aren't getting included in the builded <code>.app</code> file.</li>
  </ul>
  
  <p>Either way, I have no clue of what to do to solve it.</p>
  
  <p>How can I solve this problem?</p>
  
  <hr>
  
  <p><strong>[EDIT]</strong></p>
  
  <p>I changed that piece of code to:</p>
  
  <pre><code>NSString *tileDirectory = [[NSBundle mainBundle] resourcePath];
  </code></pre>
  
  <p>Now it works in simulator, because all files are in the apps root folder and I don't ask for it to enter another directory called "Tiles".</p>
  
  <p>This runs with no error on the simulator, but when on my iPhone it gives the original error (just a different file path but also ending with <code>/xxxx.app</code></p>
  
  <p>How can I ensure a directory in my app file such as <code>xxxx.app/Tiles</code> - TileMap does this.</p>