more compatible way of checking for sandbox, hopefully

This commit is contained in:
Jesús A. Álvarez 2016-11-21 23:07:10 +01:00
parent 7103f11578
commit 4f627541d2

View File

@ -238,13 +238,18 @@ NSString *DocumentsChangedNotification = @"documentsChanged";
#pragma mark - Files
- (BOOL)isSandboxed {
#if TARGET_IPHONE_SIMULATOR
return YES;
#else
static dispatch_once_t onceToken;
static BOOL sandboxed;
dispatch_once(&onceToken, ^{
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
sandboxed = ![bundlePath hasPrefix:@"/Applications/"];
// not sandboxed if parent of documents directory is "mobile"
NSString *documentsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject.stringByStandardizingPath;
sandboxed = ![documentsPath.stringByDeletingLastPathComponent.lastPathComponent isEqualToString:@"mobile"];
});
return sandboxed;
#endif
}
- (NSArray<NSString *> *)diskImageExtensions {