Add the option to delegate the search to the... delegate.
I used TITokenField in various app / projects (thanks for the library by the way), and a few times I needed to have either a custom search Algorithm or simply do an API call for the search.
There are various possibility to achieve that with the current TITokenField, but it is painful and add complexity.
If your delegate implement shouldUseCustomSearchForSearchString and return YES
Then performCustomSearchForSearchString is called on your delegate. Your delegate is now responsible for performing the search, you can do whatever you want including an API call. All you need to do when you have your results ready is to call completionHandler(results); (ala background fetch ^^).
In the demo project I added a fun example, try searching for contributors.
Add the option to delegate the search to the... delegate.
I used TITokenField in various app / projects (thanks for the library by the way), and a few times I needed to have either a custom search Algorithm or simply do an API call for the search.
There are various possibility to achieve that with the current TITokenField, but it is painful and add complexity.
I simply add 2 delegate methods
If your delegate implement
shouldUseCustomSearchForSearchString
and returnYES
ThenperformCustomSearchForSearchString
is called on your delegate. Your delegate is now responsible for performing the search, you can do whatever you want including an API call. All you need to do when you have your results ready is to callcompletionHandler(results);
(ala background fetch ^^).In the demo project I added a fun example, try searching for
contributors
.