containerURLForSecurityApplicationGroupIdentifier:
Returns the container directory associated with the specified security application group ID.
Discussion
As explained in App Sandbox Design Guide, groups of sandboxed apps that need to share files and other information can request a container directory as part of their entitlements. These directories are stored in
~/Library/Group Containers/
.
[NSFileManager containerURLForSecurityApplicationGroupIdentifier]
When called with a valid group identifier, this method returns the location of that directory as an
NSURL
object. This method also creates the directory if it does not yet exist.
Example of [NSFileManager containerURLForSecurityApplicationGroupIdentifier]
NSFileManager *fm = [NSFileManager defaultManager]; |
NSString *appGroupName = @"Z123456789.com.example.app-group"; /* For example */ |
NSURL *groupContainerURL = [fm containerURLForSecurityApplicationGroupIdentifier:appGroupName]; |
NSError* theError = nil; |
if (![fm createDirectoryAtURL: groupContainerURL withIntermediateDirectories:YES attributes:nil error:&theError]) { |
// Handle the error. |
} |