Reputation: 8036
Does anyone have some sample code demonstrating how to make a "file browser" view? I'd like to be able to navigate through directories and drill-down the sub-directories and see files located within the various folders. I want the user to be able to create new directories/files and even select an existing file. Is there sample code out there already available to do this?
Upvotes: 0
Views: 6620
Reputation: 2031
I'm an author of FileExplorer which is a file browser for iOS and fulfills most of your requirements. Here are some of the features of my control:
You can find my control here.
Upvotes: 0
Reputation: 10548
The iOS programming guide says that
You should never present users with the list of files in this directory and ask them to decide what to do with those files. Instead, sort through the files programmatically and add files without prompting.
This is assuming you are trying to implement file browse feature for your documents directory.
Upvotes: 2
Reputation: 31304
I don't know about sample code, but this wouldn't be too complicated to achieve using NSFileManager
and a UITableView
.
You can obtain arrays of directory contents using the subpathsOfDirectoryAtPath:error
and associated methods of a file manager. These arrays in turn can populate a UITableView
. It would be fairly easy to put together a navigation controller that could display a series of table views showing a file hiearchy.
Bear in mind, however, that you'll only be able to access the directories inside your application sandbox, unless you're running on a jailbroken device.
Upvotes: 5