From 4f627541d2dab960f43c7781610c15884dae3f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20A=2E=20A=CC=81lvarez?= Date: Mon, 21 Nov 2016 23:07:10 +0100 Subject: [PATCH] more compatible way of checking for sandbox, hopefully --- Mini vMac/AppDelegate.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Mini vMac/AppDelegate.m b/Mini vMac/AppDelegate.m index e6bcbf6..3d06066 100644 --- a/Mini vMac/AppDelegate.m +++ b/Mini vMac/AppDelegate.m @@ -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 *)diskImageExtensions {