On Feb 11, 2020, at 09:00 , Gabriel Zachmann via Cocoa-dev <cocoa-dev@lists.apple.com> wrote: > > I have a question regarding the proper handling of paths under Catalina, > some of which go through the Container, some don't. > > More specifically, I get the Pictures folder using this line of code: > > dir_to_scan = [NSHomeDirectory() stringByAppendingPathComponent: > @"Pictures/"]
Well, don’t do that. :) Instead, use one of the two NSFileManager methods that find the Pictures directory for you: URLsForDirectory:inDomains: URLForDirectory:inDomain:appropriateForURL:create:error: (You can specify nil for the “appropriateForURL” parameter.) Specify NSPicturesDirectory for the directory parameter, and NSUserDomainMask for the domain. Note that the documentation says you can use URLs in the query’s search scopes, so you don’t need to convert to paths at all. > This gives me a path like > /Users/zach/Library/Containers/com.apple.ScreenSaver.Engine.legacyScreenSaver/Data/Pictures > EXCEPT, apparently, Spotlight gives me paths starting with > /Users/zach/Pictures ! > (which does make some sense.) Yes, some of the items in the container, which are named as if they are standard directories, are actually symbolic links to the real directories outside the container. > Problem is that I can't just do > > [ array_with_all_images addObject: [path substringFromIndex: ([dir_to_scan > length] + 1)] ]; What is this supposed to be an array of? File names? Partial paths underneath ~/Pictures? If the latter, why get partial paths at all, why not just make an array of URLs? _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com