title: Get image paths from NSBundle in Objective C?
body: <p>I have about 60 images I want to store in Core Data, 30 of which are avatars and have the prefix of avt_filename_00X.png and 30 of them are smaller and have a different prefix.</p>
  
  <p>Rather than storing all the images as BLOBs in Core Data/SQLite, I want to store the paths for each image found (in the same way you would store image paths for a MySQL database).</p>
  
  <p>However I am not sure how to grab the path of the image as found in NSBundle.</p>
  
  <p>I can get the path to the NSDocumentDirectory via:</p>
  
  <pre><code>NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentsDirectory = [paths objectAtIndex:0];
  
  NSFileManager *fileManager = [NSFileManager defaultManager];
  [fileManager fileExistsAtPath:documentsDirectory];
  
  NSLog(@"documentsDirectory = %@", documentsDirectory);
  </code></pre>
  
  <p>And I can load the image and add it to an array.</p>
  
  <pre><code>if (qty == 0)
  {
      //NSLog(@"fileToLoad = %@", fileToLoad);
  
      UIImage *img = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:fileToLoad ofType:fileExt]];
  
      [self.avtList addObject:img];
  
      [img release];
  
  } else {
  
      // load multiple image into an array
      // not coded yet
  }
  </code></pre>
  
  <p>But, what I'm unsure of is:</p>
  
  <ol>
  <li><p>How do I grab the path where the computer found the image once its inside the NSBundle?</p></li>
  <li><p>How can I be sure that the path will work when the app is on a device?</p></li>
  </ol>
  
  <p>The idea would be to get all the images stored in an array and then push them to Core Data/SQLite at a later time.</p>