Hi all,
I'm trying to make an application which uses a directory contained in another application (which has made it available for discovery).
First off, I present the picker:
@IBAction func selectProject ()
{
let controller = UIDocumentPickerViewController ( documentTypes:["public.directory","public.folder"] , inMode:UIDocumentPickerMode.Open ) ;
controller.delegate = self ;
self.presentViewController ( controller , animated:true , completion:nil ) ;
}(Sidenote: what's the difference between public.directory and public.folder? Should I be using one and not the other?)
In its delegate, I try to get the contents of that directory:
func documentPicker ( sender:UIDocumentPickerViewController , didPickDocumentAtURL url:NSURL )
{
rootURL = url ;
do {
try contents = fileManager.contentsOfDirectoryAtURL ( rootURL! , includingPropertiesForKeys:nil , options:NSDirectoryEnumerationOptions(rawValue:0) ) ;
} catch let error as NSError {
contents = [] ;
print ( "Failed to get contents of \(rootURL): \(error)" ) ;
}
self.tableView.reloadData() ;
}The operation, however, fails:
Failed to get contents of Optional(file:///private/var/mobile/Containers/Shared/AppGroup/A497BA66-EA97-4658-BD4B-013ABBBB247A/File%20Provider%20Storage/git-ascii-bundle/): Error Domain=NSCocoaErrorDomain Code=257 "The operation couldn’t be completed. (Cocoa error 257.)" UserInfo=0x174270f80 {NSURL=file:///private/var/mobile/Containers/Shared/AppGroup/A497BA66-EA97-4658-BD4B-013ABBBB247A/File%20Provider%20Storage/git-ascii-bundle, NSFilePath=/private/var/mobile/Containers/Shared/AppGroup/A497BA66-EA97-4658-BD4B-013ABBBB247A/File Provider Storage/git-ascii-bundle, NSUnderlyingError=0x174059410 "The operation couldn’t be completed. Operation not permitted"}I have no idea why this would be happening... I tried to get the path from the url and use contentsOfDirectoryAtPath, but that didn't work either.
Any suggestions would be greatly appreciated!