title: iOS CoreData custom search cancel on text field change
body: <p>I have a TextField that is search in my app, I have added the event Editing Changed, but when I type fast CoreData is not able to search so rapidly so the results are not precise.</p>
  
  <p>Currently I'm using such script:</p>
  
  <pre><code>[self-&gt;_searchThread cancelAllOperations];
  NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(performSearch:) object:((UITextField *)sender).text];
  [self-&gt;_searchThread addOperation:operation];
  </code></pre>
  
  <p>in performSearch I add all the predicates run through results and format them and then call:</p>
  
  <pre><code>[self performSelectorOnMainThread:@selector(setSearchResults:) withObject:@[[NSArray arrayWithArray:data]] waitUntilDone:NO];
  </code></pre>
  
  <p>I thought using <code>[self-&gt;_searchThread cancelAllOperations];</code> would cancel current request and start a new one immediately but it does not seem to work like that. Is there any way I can cancel the current running search and start new once user changes the TextField, or are there any other solutions?</p>
  
  <p>Thanks. </p>