addobserver forkeypath breaks NSMetadataQuery live updates?
addobserver forkeypath breaks NSMetadataQuery live updates?
- Subject: addobserver forkeypath breaks NSMetadataQuery live updates?
- From: Derrek Leute <email@hidden>
- Date: Fri, 8 Jul 2005 23:50:05 -0400
The subject line says it all. If I add an observer like this:
[self addObserver:self forKeyPath:@"groupQuery.results"
options:NSKeyValueObservingOptionNew context:nil];
NSMetadataQuery stops "working" after a single live update happens. I
am using observeValueForKeyPath to perform some logic on items as the
change dictionary provides them. Also, it calls
observeValueForKeyPath twice providing the first results both times
in the change dictionary. It then updates once if I change a file and
no longer after that. If I use a notification center and remove
addObserver it works fine but I don't get live updates. I wait for a
didFinish gathering notification, disableUpdates, cycle through the
query as necessary and then enableUpdates.
Is there a way to get live-updates that doesn't break
NSMetadataQuery? Would manual bindings work better in this situation?
An additional complication is I'd like to use coredata to store
kMDItemPath values from the query results so when my application
restarts the user doesn't have to wait for "fresh" results from
several spotlight searches to use the interface. To do this I need to
add new results during the gathering phase and remove stale results
after the search finishes. Then intersect results for any live-
updates that happen. This logic appeared to be working with
observeValueForKeyPath except that addObserver breaks live updates.
I suspect it breaks live updates because whatever gets the change
dictionary doesn't know to send disableUpdates to a query before
getting results. Is there something I can override that would make
addObserver send disableUpdates and then enableUpdates when it gets
the changes?
I hope that was clear.
Thanks!
--Derrek
_______________________________________________
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