Waiting for NSMetadataQuery to finish?
Waiting for NSMetadataQuery to finish?
- Subject: Waiting for NSMetadataQuery to finish?
- From: Knud Hinnerk Möller <email@hidden>
- Date: Wed, 18 Oct 2006 19:17:44 +0100
Hi,
is it somehow possible to wait for an NSMetadataQuery to first give
back some results, and only then continue in the code?
Here is my situation: in an NSTextView I want to run a Spotlight
query on autocomplete and fill the autocomplete drop-down box with
the results of the query.
Here is what I do:
- Within NSTextView's
completionsForPartialWordRange:indexOfSelectedItem: I construct an
NSPredicate with the current partial word, along the lines of
(kMDItemDisplayName like[cd] '*word*') (actually, the query is a bit
more restricted).
- I register a handler method (queryHandler:) for
NSMetadataQueryDidFinishGatheringNotifications.
- I run the query with the predicate.
- queryHandler: iterates over the query results and constructs an
array of autcomplete suggestions from it.
- Now, what is a clever way to make
completionsForPartialWordRange:indexOfSelectedItem: return that array?
I suppose I could somehow halt
completionsForPartialWordRange:indexOfSelectedItem: until [query
hasStopped] or ![query isGathering], but that doesn't seem to work
just like that. Do I have to work with threads here? Should I take a
completely different approach? Any suggestion is welcome!
Cheers,
Knud
-------------------------------------------------
Knud Möller, MA
+353 - 91 - 495086
Digital Enterprise Research Institute
National University of Ireland, Galway
Institiúid Taighde na Fiontraíochta Digití
Ollscoil na hÉireann, Gaillimh
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden