Search Field and Table View


I have a search field and a table view in my app. When something is typed in the search field, I want it to filter out the results from the table view from the text typed into the search field, so say if I typed “Hi” into the search field, it would filter out everything in the table view that contained “Hi” in data column “names”.


ever figure this out? I am looking to do something similar.

I did. But not as easy as it would be in AppleScriptObjC!

First, forget about a “filter-as-you-type” kinda search. Tried many times to make it work, was soooo problematic and unstable. But “send on end editing” works fine.

The gist of it is simple, the code is less. You have a data source that contains the original info. You initialize another data source at launch that is empty and will be the filtered data source. then when the user either hits tab or return, you collect the string to search for and you do a repeat loop for each data row in the original data source and you copy info from the original DS to the “search” DS as you find them. Then you tell the table view to use the “search” DS instead of the original DS to show the info.

Actually found the info here in the forums, but can’t remember where or who. Had to modify the code a lot to make it work ok, and fast too, because I have a 2000+ entry datasource to filter… kinda fast, like between 1 and 2 seconds, depends on the number of hits…

I know that it would be possible to do a easier “filter-as-you-type” with help of ObjC and IB, as can be done in ASOC. I tried to translate the code and idea of the ASOC version, but without ObjC, I dont think it is possible. Unless someone has successfully made it work?

If you need help with the code, let me know, i’ll try to post as much as I can…

Browser: Safari 531.9
Operating System: Mac OS X (10.6)