-1

I used the following code to get the documents

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
if([paths count] > 0)
{
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSLog(@"%@",documentsDirectory);
    NSError *error = nil;
    NSArray *documentArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:&error];
    if(error)
    {
        NSLog(@"Could not get list of documents in directory, error = %@",error);
    }
    else
    {
        NSLog(@"Hello %@",documentArray);
        arrdocument = documentArray;
    }
}

But it only show documents within my application, Not the outside of the application.

  • What other documents do you want to access? – rmaddy Apr 26 '16 at 13:55
  • This is how sandboxing works. An iOS application is limited to it's sandbox, and any other resources the user provides (e.g. via the iCloud documents picket). – yaakov Apr 26 '16 at 13:56

3 Answers3

1

You cannot access files in other applications : each app is sandboxed.

I suggest you to read the File System Basics from Apple :

Every App Is an Island

An iOS app’s interactions with the file system are limited mostly to the directories inside the app’s sandbox. During installation of a new app, the installer creates a number of containers for the app. Each container has a specific role. The bundle container holds the app’s bundle, whereas the data container holds data for both the application and the user. The data container is further divided into a number of directories that the app can use to sort and organize its data. The app may also request access to additional containers—for example, the iCloud container—at runtime.

These containers constitute the app’s primary view of the file system.

Because it is in a sandbox, an app is generally prohibited from accessing or creating files outside its containers. One exception to this rule occurs when an app uses public system interfaces to access things such as the user’s contacts or music. In those cases, the system frameworks handle any file-related operations needed to read from or modify the appropriate data stores.

Michaël Azevedo
  • 3,874
  • 7
  • 31
  • 45
1

You cannot access files in other applications : YES.

But apple provides way to design NSDocument based app to share files outside sandbox, which is a common shared folder for all app having root common bundle identifier.

Besides that you can use iCloud public store also to share data between other app(like Flicker, dropbox). below are some tutorial links :

https://www.raywenderlich.com/12779/icloud-and-uidocument-beyond-the-basics-part-1

https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/DocumentBasedAppPGiOS/DocumentArchitectureiniOS/DocumentArchitectureiniOS.html

kaushal
  • 1,553
  • 18
  • 25
0

Every App Is an Island

An iOS app’s interactions with the file system are limited mostly to the directories inside the app’s sandbox. During installation of a new app, the installer creates a number of containers for the app. Each container has a specific role. The bundle container holds the app’s bundle, whereas the data container holds data for both the application and the user. The data container is further divided into a number of directories that the app can use to sort and organize its data. The app may also request access to additional containers—for example, the iCloud container—at runtime.

https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html

Community
  • 1
  • 1
Jeyamahesan
  • 1,101
  • 7
  • 15