1

I have an NSView drop box, which allows the user to drag and drop a folder. I don't want them to drag and drop the very folders like ~ Movies, ~ Music, ~ Desktop... inside User's folder. If I run the following code, what I get is a movies folder assigned to my sandboxed application. That's not what I want.

NSURL *url = [[NSURL alloc] init];
url = [[[NSFileManager defaultManager] URLsForDirectory: NSMoviesDirectory inDomains:NSUserDomainMask] lastObject];
NSLog(@"%@",[url path]);

I can get the right folder with 'url' above by repeating stringByDeletingLastPathComponent several times. But is there a simpler way of getting that folder? And is there a way of preventing the user from using those folders right inside the local user folder altogether?

Mucho thankos

El Tomato
  • 6,479
  • 6
  • 46
  • 75
  • You're talking a lot about the things you *don't* want the user to do, but what is the desired outcome here? Specifically. –  May 02 '15 at 05:48
  • Suppose that I have an application that allows the user to delete files and folders. The application should not delete those folders. Files inside those folder might be acceptable. In a case like that, I need to list some paths that need to be rejected. – El Tomato May 02 '15 at 06:29

1 Answers1

2

The answer to How do I get the users home directory in objective-c in a sandboxed app? shows you how to determine the path to the user's home directory. Once you have that you can use it in determining if a dropped folder is an immediate child of the home folder and reject it.

HTH

Community
  • 1
  • 1
CRD
  • 52,522
  • 5
  • 70
  • 86