2018-04-13 00:03:34 UTC
I have a sandboxing question, below. I'm wondering if it's even possible to do what I tried to do, and if so, how?
I'm trying to iterate directories in a sandboxed app in order to find a file with a specific extension.
I believe I have all the entitlements that are available that might help:
I need to be able to find a file, by name, that could either be on the Desktop or in the (real) Documents folder. I don't even get close. I get a filecoordinationd when I try to iterate either of them (code below). I am able to find a file, by name, in the Downloads folder, though.
Has anyone been able to do this with the Desktop folder or the (real) Documents folder? (When I used NSDocumentDirectory it looked in the Documents folder attached to my container. I could find things that were in that. But it wasn't the same as the Documents folder that the user sees.)
If I turn off Sandboxing I have no problem iterating Desktop or Documents.
This is the code I used to test iterating in three NSSearchPathDirectories: NSDocumentDirectory, NSDesktopDirectory, and NSDownloadsDirectory.
NSFileManager* fm = [NSFileManager new];
NSError* err = nil;
NSURL* rootDirURL =
// error-checking omitted
NSURL * theFormsFolderURL = [self formsFolderURL:rootDirURL];
- (NSURL *) formsFolderURL:(NSURL *)rootDirURL
NSFileManager * fm = [NSFileManager defaultManager];
NSDirectoryEnumerator* dir = [fm enumeratorAtURL:rootDirURL
for (NSURL* f in dir)
if ([[f pathExtension] isEqualToString:@"pdq"])
NSLog(@"%@", [f lastPathComponent]);
return nil; // Dummy nil
BTW, this was the value that gave me a filecoordinationd for Desktop:
rootDirURL NSURL * @"file:///Users/joely/Library/Containers/biz.pdqforms.pdqforms/Data/Desktop/"
Cocoa-dev mailing list (Cocoafirstname.lastname@example.org)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to ***@ml-in.narkive.net