diff ios/dw.m @ 2445:a773008c7c5d

iOS: Make sure the plain text UTI is used with filePicker. Also strip off the "file://" prefixing the file path returned.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 09 Apr 2021 11:05:51 +0000
parents ba24ddb19a43
children 8723c01fb87e
line wrap: on
line diff
--- a/ios/dw.m	Fri Apr 09 10:01:22 2021 +0000
+++ b/ios/dw.m	Fri Apr 09 11:05:51 2021 +0000
@@ -977,7 +977,18 @@
     char *file = NULL;
 
     if(url && [[url absoluteString] length] > 0)
-        file = strdup([[url absoluteString] UTF8String]);
+    {
+        const char *tmp = [[url absoluteString] UTF8String];
+
+        if(tmp)
+        {
+            /* Strip off file:// so it looks the same as other platforms */
+            if(strncmp(tmp, "file://", 7) == 0)
+                file = strdup(&tmp[7]);
+            else
+                file = strdup(tmp);
+        }
+    }
     dw_dialog_dismiss(dialog, file);
 }
 -(void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller
@@ -1090,7 +1101,7 @@
         mode = UIDocumentPickerModeExportToService;
     /* Try to generate a UTI for our passed extension */
     if(ext)
-        UTIs = [NSArray arrayWithObject:[NSString stringWithFormat:@"public.%s", ext]];
+        UTIs = [NSArray arrayWithObjects:[NSString stringWithFormat:@"public.%s", ext], @"public.text", nil];
     else
         UTIs = @[@"public.text"];
     picker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:UTIs inMode:mode];