Search code examples
iosobjective-cnsfilemanager

How to search all directories? Objective C


I know how to search a directory for a file(s) using NSFileManager. But I want to search all directories in iphone to find files with some extension (let's say .txt). How can I do that?


Solution

  • The files that an app can access are those in the app's sandbox. This means you can access only those files that originated(directly or indirectly) from your app. Complete unrestricted access to the iOS file system is not possible as of now.

    However I think it is worth noting that iOS 11 has introduced some changes that do allow you to view the document directories of other apps. This is possible only if those apps have made their documents directory public using the 'UISupportsDocumentBrowser'key in their info.plist. Again this depends on how the other apps are coded and might not be of help in your case.