在Mac Catalyst应用程序中使用UIDocumentPickerViewController读取文件需要读/写授权吗?

问题描述 投票:1回答:1

我在UIViewController中有此代码,确认为UIDocumentPickerDelegate

- (void)openTextFilePicker {
    NSArray *UTIs = [NSArray arrayWithObjects:@"public.text", nil];
    [self openFilePicker:UTIs];
}

- (void)openFilePicker:(NSArray *)UTIs {
    UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:UTIs inMode:UIDocumentPickerModeImport];
    documentPicker.delegate = self;
    documentPicker.popoverPresentationController.barButtonItem = self.importButton;
    [self presentViewController:documentPicker animated:TRUE completion:nil];
}

- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURLs:(NSArray<NSURL *> *)urls {
    [self documentPicker:controller didPickDocumentAtURL:[urls firstObject]];
}

- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
    NSLog(@"picked document %@", url);
}

- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller {
    NSLog(@"cancelled");
}

这允许用户在系统上的任何位置选择文件,并将其内容导入应用程序。如果我将“应用程序沙箱”>“用户选择的文件”功能设置为“读/写”,则可以使用。但是我只从文件中读取数据,不需要更新文件或保存沙箱以外的任何内容。因此,我将功能更改为“只读”,但随后在控制台中收到此错误,并且没有调用didPickDocumentsAtURLs

无法为[路径]创建FPSandboxingURLWrapper。错误:错误域= NSPOSIXErrorDomain代码= 1“无法为'[路径]'发出沙盒扩展名com.apple.app-sandbox.read-write:不允许操作”

这似乎是正确的,还是我应该能够仅以只读权限读取文件?如果需要,可以很容易地将其切换为“读/写”,但是我的第一份提交由于使用了不必要的权利而被拒绝,如果确实需要,我希望准备向审核小组提出理由。

macos appstore-sandbox entitlements maccatalyst
1个回答
0
投票

我继续将权利更改为读/写,并在“应用程序沙箱信息”字段中添加了注释,并说明了如何使用文件访问权限。该应用程序已获批准。

© www.soinside.com 2019 - 2024. All rights reserved.