Open file dialog in iOS?


#1

What are people using to open a file on an iPad? I stuck in a standard FileChooser dialog, but that just looks wrong somehow. Maybe because I’ve never seen an open dialog in a native iPad app.

Is the standard operating procedure to open the dialog to a particular folder within the installed app’s bundle, and use that as the space to store and open applications that my app recognizes? What’s the default location that iTunes will look for files to transfer off the device, or to the device?


#2

I don’t think Apple provide any kind of file chooser in iOS, do they? I’ve never seen one on my iPhone.


#3

nope, apple are quite big on the idea that - as far as the user is concerned - there is no filesystem [therefore there’s one less barrier to entry of the grok party]. There are apps which provide their own local (sandboxed) filing schemes, but nothing systemwide (except for the various media libraries).


#4

That doesn’t seem to be entirely true. Files can be transferred back and forth between your Mac and your iOS device using iTunes, if you set uifilesharingenabled to true in your info.plist.

Apple’s Documentation (http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/StandardBehaviors/StandardBehaviors.html) says that you can use the NSSearchPathForDirectoriesInDomains call to access this folder, which is really a “Documents” folder within your application bundle:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0];

I haven’t been able to get a file to my juce iOS application via iTunes yet, but its clear that the infrastructure for doing so is present in iOS.


#5

OK, I found the right path to the Documents directory:

theDocumentsDirectory = File::getSpecialLocation(File::currentExecutableFile).
getParentDirectory().getSiblingFile(“Documents”);

You can open files that are there using the FileChooser, but as haydnx pointed out, that really doesn’t feel right. The object on iOS is to hide the whole directory structure from the user.


#6

Yeah, there’s nothing stopping you from using files in an app-defined manner (and they can be exposed for iTunes to sync to a computer), but my point was that there is no iOS file-system presented to the user of the device. Any files an app generates/uses are managed in its own manner; there is no common interface for managing files on the device itself beyond the basic media library.


#7

I stumbled over this today and noticed that the path to the Documents folder is not ( or no longer ) correct.
Should be:

without the getParentDirectory() part

Cheers