On Jan 10, 2020, at 07:36:03, Gabriel Zachmann via Cocoa-dev <cocoa-dev@lists.apple.com> wrote: > > So, is .../Containers/.../Data/Pictures linked to ~/Pictures automatically?
Yes. That's under-the-hood stuff that you should mostly ignore. Pretend it doesn't exist. The OS will do what it needs to do. > I am searching that directory (if the user did not specify any other > directory) for images using Spotlight. > Apparently, Spotlight starts delivering images to my screensaver, and at some > point it gets killed or hangs. I was wondering if that happens when > Spotlight tries to deliver images from the Photos database (which is also > stored in ~/Pictures). I dunno. Is there some error returned? > Do I have to do anything special to ensure that? > Currently, I am using this very simple code: > > - (IBAction) selectDirectory: (id) __attribute__ ((unused)) sender > { > NSOpenPanel *oPanel = [NSOpenPanel openPanel]; > long int result; > > NSURL * url = [[oPanel URLs] objectAtIndex: 0]; You can also just use oPanel.URL if you only expect 1 file, otherwise you should loop through oPanel.URLs. > NSString * aDir = [url path]; As long as you're not storing and reloading that path, but storing and loading security scoped bookmarks to urls instead, using a path created at runtime is fine. I prefer using urls instead, because that way you don't have to worry about some of this stuff. Most APIs that accept a path also have methods that use an NSURL. I suggest you use them. >> and I store security-scoped bookmark data for each url they choose. > > How do I do that? how would I use such url's? > Could you explain this a bit further, or maybe you can provide a pointer > where I can read up on this? Read this entire document - all sections. It explains the Container, security scoped bookmarks, etc. In fact, read it a couple times. https://developer.apple.com/library/archive/documentation/Security/Conceptual/AppSandboxDesignGuide/AboutAppSandbox/AboutAppSandbox.html Then look for examples of using: bookmarkDataWithOptions:includingResourceValuesForKeys:relativeToURL:error: URLByResolvingBookmarkData:options:relativeToURL:bookmarkDataIsStale:error: and startAccessingSecurityScopedResource stopAccessingSecurityScopedResource The last two are important - always balance the use of one with the other. -- Steve Mills Drummer, Mac geek _______________________________________________ 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