- Fix for wrong path of restored game ios-revival
authorantonc27 <antonc27@mail.ru>
Thu, 15 Oct 2015 01:13:23 +0200
branchios-revival
changeset 11211 279ed2931be8
parent 11210 2e80c9861818
child 11212 89f6c8cf60c8
- Fix for wrong path of restored game Note: http://stackoverflow.com/questions/25884382/ios-8-bundle-path-changes
project_files/HedgewarsMobile/Classes/RestoreViewController.m
--- a/project_files/HedgewarsMobile/Classes/RestoreViewController.m	Wed Oct 14 21:25:49 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/RestoreViewController.m	Thu Oct 15 01:13:23 2015 +0200
@@ -38,7 +38,14 @@
     if (theButton.tag != 0) {
         [[AudioManagerController mainManager] playClickSound];
         [GameInterfaceBridge registerCallingController:self.presentingViewController];
-        [GameInterfaceBridge startSaveGame:[[NSUserDefaults standardUserDefaults] objectForKey:@"savedGamePath"]];
+        
+        // Since iOS 8, the file system layout of app containers has changed.
+        // So, we must rely now on saved game filename, not full path.
+        NSString *oldSavedGamePath = [[NSUserDefaults standardUserDefaults] objectForKey:@"savedGamePath"];
+        NSString *savedGameFile = [oldSavedGamePath lastPathComponent];
+        NSString *newSavedGamePath = [NSString stringWithFormat:@"%@%@", SAVES_DIRECTORY(), savedGameFile];
+        
+        [GameInterfaceBridge startSaveGame:newSavedGamePath];
     } else {
         [[AudioManagerController mainManager] playBackSound];
         [defaults setObject:@"" forKey:@"savedGamePath"];