I've been trying to access the NSMetaData information for mb4 objects that I legally downloaded from third party websites without DRM protection. I posted a request in the app forum before and didn't receive any responses from anyone, so it occurred to me to use the example apple code provided on NSMetaData Objects.
Steps to reproduce: download the "simpleiclouddocument" example and changed the document extension to Mb4. It seems the query fails because the documents are outside the application directory, so I expanded the search scope to include "NSMetaDataQueryAccessibleExternalDocumentsScope" and the files are still not found.
I have the URL of the file that I want the MetaData for. I understand that NSMetaData has an init object that works with a URL but it only works on MacOS and not iOS. I have alternatively tried using LPLinkPresentation and AVMetdataItem but these two alternatives appear to limit the metadata fields I can access and there is no additional object data on how to expand the links to access the other metadata items associated with the file, specifically the Author field as Mb4 files have authors in addition to other audio metadata settings. If there is additional information somewhere on those two classes that identifies how I can access the rest of the metadata fields that would likewise correct my problem.
Post
Replies
Boosts
Views
Activity
I've been trying to grab the NSMetaDataItems for a collection of items in a known file location outside the main App Container (I want to manage the documents in place rather than copying them into the app container to manage). I think I've worked out the code to start the query, but the NSMetadataQueryDidFinishGathering notification is never being called. I've tried changing the predicate comparator from '==' to '==[cd]' to 'LIKE' to 'BEGINSWITH' and nothing works. I also found a resource that said it was because it's not being called on the main queue, so I added code for that. But it's still not being called. I've been stumped on this for months. Any help would be appreciated.
NotificationCenter.default.addObserver(self, selector: Selector(("initialGathercomplete:")), name: NSNotification.Name.NSMetadataQueryDidFinishGathering, object:nil)
metadataQuery.notificationBatchingInterval = 1
metadataQuery.searchScopes = [NSMetadataQueryUbiquitousDataScope]
metadataQuery.predicate = NSPredicate(format: "%K ==[cd] %@", NSMetadataItemPathKey, libraryPath)
metadataQuery.sortDescriptors = [NSSortDescriptor(key: NSMetadataItemFSNameKey, ascending: true)]
DispatchQueue.main.async{
self.metadataQuery.start()
}