Is there any way to use a NSBundle
from the documents folder on iOS?
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 viewWillAppear
method use:
// 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]);
// ---------------
if you want to know what is in the documents folder (the one you can actually browse in the iOS Simulator
via ~/YourUserName/Library/Application Support/iPhone Simulator/versioOfSimulator/Applications/appFolder/Documents)
you would use NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
instead.
Hope it helps you, mate!