Copy file from iOS 11 Files app to sandbox

孤街醉人 提交于 2019-12-06 13:29:14
Hyndrix

Here is how you can access the files and stop when are done with it.

//To gain access
[nsUrl startAccessingSecurityScopedResource]

and

//To stop access
[nsUrl stopAccessingSecurityScopedResource]

i have the same issue to Copy file from iOS 11 Files app to sandbox . finally i solved my issue this link check here

and the sample code .

[fileURL startAccessingSecurityScopedResource];//fileURL ---> Which FileURL you want to copy

                NSFileCoordinator *fileCoordinator = [[NSFileCoordinator alloc] initWithFilePresenter:nil];

                NSFileAccessIntent *readingIntent = [NSFileAccessIntent readingIntentWithURL:fileURL options:NSFileCoordinatorReadingWithoutChanges];

                [fileCoordinator coordinateAccessWithIntents:@[readingIntent] queue:[NSOperationQueue mainQueue] byAccessor:^(NSError *error) {

                    NSData *filePathData;

                    if (!error)
                    {
                        // Always get URL from access intent. It might have changed.
                        NSURL *safeURL = readingIntent.URL;

                     // here your code to do what you want with this 

                    }

                    [fileURL stopAccessingSecurityScopedResource];

                }];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!