Been searching high and low for this:
In Core Data, is there a way to interrupt/stop/cancel and executing NSFetchRequest?
I’m implementing an incremental search in an iPhone app, and I’ve tried every way of optimizing it, but it’s not enough (I have 42,000 records), so I have to run it in an NSOperation. When a new character is typed, I need to cancel the previous fetchRequest, but [nsoperation cancel] does nothing.
Another approach might be to move the field I’m searching on into some other interruptible index, maybe in memory, or maybe a separate sqlite3 database, which appears to be interruptible with sqlite_interrupt.
My solution was to let the query operations keep running, but to check if they’d been cancelled before sending the event to update the UI.
This isn’t perfect because you can still have a lot of query operations running, the results for which will never be used, but it is still quite a bit faster.