Questions about sandboxing under Catalina
Questions about sandboxing under Catalina
- Subject: Questions about sandboxing under Catalina
- From: Gabriel Zachmann via Cocoa-dev <email@hidden>
- Date: Wed, 8 Jan 2020 22:29:47 +0100
I have two questions regarding sandboxing.
1.
In my screensaver, I try to search the Pictures directory in the user's home.
It is OK - for now - if my app cannot access any .photoslibrary, but I'd like
to pick up
any other images in ~/Pictures.
I get the path using this line of code:
[NSHomeDirectory() stringByAppendingPathComponent: @"Pictures/"]
However, when I print the actual path to the system log, it says it is
accessing this path:
/Users/me/Library/Containers/com.apple.ScreenSaver.Engine.legacyScreenSaver/Data/Pictures
Is this directory somehow linked to ~/Pictures ?
Or how can I access the true ~/Pictures directory ?
(Under Mojave, my screensaver can access ~/Pictures just fine - except for any
.photoslibrary, which is OK, sort of, for the moment.)
2.
Also, I am trying to read some data from a file in Application Support.
So far, I do that like this:
NSFileManager *fmanager_ = [NSFileManager defaultManager];
NSArray * appSupportDir = [fmanager_ URLsForDirectory:
NSApplicationSupportDirectory
inDomains: NSUserDomainMask ];
NSURL * url = [ [appSupportDir objectAtIndex: 0] URLByAppendingPathComponent:
@"ArtSaver" ];
NSString * folder = [url path];
NSError * theError = nil;
[fmanager_ createDirectoryAtPath: folder withIntermediateDirectories: YES
attributes: nil error: &theError];
NSURL * url = [ [appSupportDir objectAtIndex: 0] URLByAppendingPathComponent:
@"ArtSaver" ];
NSString * folder = [url path];
NSError * theError = nil;
fmanager_ createDirectoryAtPath: folder withIntermediateDirectories: YES
attributes: nil error: &theError];
path = [folder stringByAppendingPathComponent: [NSString stringWithFormat:
@"LastRunInfo.%@.plist", displayname] ];
lastRunInfoPath_ = [NSURL fileURLWithPath: path isDirectory: NO];
When I print lastRunInfoPath_ , I get
lastRunInfoPath =
file:///Users/me/Library/Containers/com.apple.ScreenSaver.Engine.legacyScreenSaver/Data/Library/Application Support/ArtSaver/LastRunInfo.plist
Can I continue with this just as before under Mojave?
Will info stored in such a plist be persistent?
Best regards, Gabriel
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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 email@hidden