I'm seeing some weird behavior with NSItemProvider and PHPickerViewController.
For some reason loadItem fails until I've used loadFileRepresentation on that same video.
itemProvider.loadItem(forTypeIdentifier: "public.movie", options: nil) { url, error in
guard let url = url as? URL else {
return
}
print(FileManager.default.fileExists(atPath: url.path))
}
This prints false.
itemProvider.loadFileRepresentation(forTypeIdentifier: "public.movie") { url, error in
print(FileManager.default.fileExists(atPath: url.path))
}
This prints true.
Now if I change the code to use loadItem and select the video that I just used loadFileRepresentation on, it works correctly.
I would happily use loadFileRepresentation all the time, but it loads extremely slowly. ~20 seconds for a minute long video, while loadItem takes about .1 seconds for the same video.
What's going on here?