I am writing an app that can be sent multiple URLs, either by another app sending those URLs, or by someone selecting them in Finder and clicking "Open with…".
Here is the code that receives the URLs :
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate
{
func application(_ application: NSApplication, open urls: [URL])
{
DataProvider.clear()
for url in urls
{
DataProvider.addURL(url)
}
NotificationCenter.default.post(name: .onDataLoaded, object: nil)
}
The problem I have is that not all of the URLs are received at the same time, therefore, clearing the DataProvider down as I would want to do after each drop, gets called part way through a single drop.
e.g. I send 9 URLs but only 5 get processed in one call, followed by the other 4 in another call.
I'm guessing this has something to do with asynchronous handling but, apart from setting up a timer to delay clearing DataProvider in the case of a second drop within a given timespan, I'm at a bit of a loss to solve this problem.
Anyone got any better ideas please?