I am aware that on iOS you can only use NSMetadataQuery
for iCloud files. However, according to Apple's guide, you can still get NSMetadataItem
by searching for the file you want manually with FileWrapper
:
iOS allows metadata searches within iCloud to find files corresponding files. It provides only the Objective-C interface to file metadata query,
NSMetadataQuery
andNSMetadataItem
, as well as only supporting the search scope that searches iCloud.Unlike the desktop, the iOS application’s sandbox is not searchable using the metadata classes. In order to search your application’s sandbox, you will need to traverse the files within the sandbox file system recursively using the
NSFileManager
class. Once matching file or files is found, you can access that file in the manner that you require. You are also able to use theNSMedatataItem
class to retrieve metadata for that particular file.
However, I couldn't find a way to get the NSMetadataItem
from a local file on iOS sandbox. You can initialize NSMetadataItem
from a file URL but that's available only on macOS. FileManager
also doesn't seem to have an API to retrieve NSMetadataItem
from it.
How do I get NSMetadataItem
for local files on iOS App Sandbox?