My app has a 5 modules and each modules data was stored in 5 different managed object. I created a search page, where the user can type a keyword to find the keyword in all the 5 modules. For each text change in search bar, I refreshed the search result table to show the matching records count along with the module name.
So, for each press in search bar, I need to fetch the matching datas count from all 5 modules. This is simple if the app has minimal amount of records. But, in my case, the total record count was so heavy, so the time taken by fetching data from 5 modules by the typed search word was so huge and it makes the app freeze.
I have no idea about implementing thread concept in iOS, so I tried to learn by reading Apple’s threading programming guide and concurrency programming guide. I hope, I gained some knowledge about threads, but it’s somewhat complex when I try to implement those concepts by code.
My requirement is, I have some 5 functions which should be called using thread concept. Consider the functions are,
function1() {...}
function2() {...}
function3() {...}
function4() {...}
function5() {...}
I want to call these 5 functions in the same time so that no one can wait for others completion. One more point is, when the above functions fetching the records, if the user type/erase a text in searchbar, I want to cancel/stop all threads, and I need to perform another new 5 calls to these functions.
I’m looking for suggestions, any kind of working sample codes, examples. Any help would be greatly appreciated.
Thanks
There’s a good post about Core Data and background threading here! With the whole GCD stuff this is not so hard to acomplish anymore, so this is maybe a good entry point for further research on this topic.
And here is another post to this topic.