0

My app allows users to create and delete files from the documents folder within the app. They can do it through the app itself or manually using itunes. Is there are way to access what's left in the documents folder without any hardcoding of the filenames?

Thank you.

Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
Tom
  • 1

1 Answers1

1

You can get NSArray with all items in given directory using contentsOfDirectoryAtPath:error: method in NSFileMamanger:

NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSArray *allItems = [[NSFileManager sharedFileManager] contentsOfDirectoryAtPath:documentsDirectory error:NULL];
Vladimir
  • 170,431
  • 36
  • 387
  • 313