Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Not sure what the exact question is, either, but here is how I access the local document folder of my app (this is not the documents folder where you store sources your app uses, but the one your app stores local resources) for example, in my app I take pics with the camera and store them to the app's local folder, not the device camera roll, so to get the number of images I do this, in the <code>viewWillAppear</code> method use:</p> <pre><code>// create the route of localDocumentsFolder NSArray *filePaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //first use the local documents folder NSString *docsPath = [NSString stringWithFormat:@"%@/Documents", NSHomeDirectory()]; //then use its bundle, indicating its path NSString *bundleRoot = [[NSBundle bundleWithPath:docsPath] bundlePath]; //then get its content NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:bundleRoot error:nil]; // this counts the total of jpg images contained in the local document folder of the app NSArray *onlyJPGs = [dirContents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self ENDSWITH '.JPG'"]]; // in console tell me how many jpg do I have NSLog(@"numero de fotos en total: %i", [onlyJPGs count]); // --------------- </code></pre> <p>if you want to know what is in the documents folder (the one you can actually browse in the iOS Simulator </p> <blockquote> <p>via ~/YourUserName/Library/Application Support/iPhone Simulator/versioOfSimulator/Applications/appFolder/Documents)</p> </blockquote> <p>you would use <code>NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];</code> instead.</p> <p>Hope it helps you, mate!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload