Reputation: 450
I am trying to make an application that open different office document for iphone. Iam new to IOS development. I want to ask if there is something similar to file chooser dialog box as one get open when we click open file on our desktop.
Upvotes: 3
Views: 5738
Reputation: 8412
Nope, you have to fetch the files in a folder using NSFileManager
and fill a UITableView
. You can for instance use -contentsOfDirectoryAtPath:error:
. See more in the NSFileManager Class Reference.
Some code:
// Getting Files at "directory"
NSError *error = nil;
NSFileManager *manager = [NSFileManager defaultManager];
NSArray *files = [manager contentsOfDirectoryAtPath:directory error:&error];
// Iterating through files looking for certain file extensions
// _fileTypes_ is an array of extensions, e.g. [NSArray arrayWithObject:@"txt"];
for (NSString *fileName in files)
{
if ([_fileTypes_ containsObject:[fileName.pathExtension lowercaseString]])
{
// Do something with fileName, e.g. adding it to an array and showing it lager in a UITableView
}
}
Upvotes: 3