gonzobrains gonzobrains - 4 days ago 5
iOS Question

iOS file browser example

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?

lxt lxt
Answer

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.

Comments