https://github.com/skurfer/Spotlight-qsplugin/tree/notifications
All you need to be looking at is QSSpotlightObjectSource. I’ve tried scanning a source dozens of times, but the `arrayLoaded:` method has only been called two or three times and I can’t figure out why. I’ve done the same searches in another stand-alone project and it finishes and sends the notification quickly and consistently.
Any ideas why it almost never sees the notification? Searching suggests that `startQuery` has to be run on the main thread, but as you can see, I’ve done that.
Probably not related to my problem, but I’m also not sure about having a single NSMetadataQuery object for the class. If I’m not mistaken, one instance of the class will handle all entries of that type, so I probably need an NSMetadataQuery for each entry and not just the class, right? But for testing purposes, I’ve removed all but one Spotlight entry and it still isn’t working as expected.
--
Rob McBroom
<http://www.skurfer.com/>
A very quick thought off the top of my head: Is the notification send by Quicksilver, or the OS? So should you be using NSDistributedNotificationCenter?
Adding the CFRunLoop() business got it working again, but I’m really not comfortable leaving that in there until I understand what it’s doing, so more R’ing of TFM awaits.
Long story short, the behavior when scanning catalog entries is not at all consistent. In order from most to least broken, these ways to trigger a scan all behave a little differently:
- Manually rescanning with the arrow in the preferences
- Scanning with the “Rescan Catalog Entry” action
- Allowing the scan to happen normally in the background
- Enabling the entry by checking the box next to it