views:

204

answers:

1

Hello friends.

I am building an application with coredata. Its nearly finished but i have a problem.

I want to put a search section on my application. I did it now and it is working, but there is something weird and i could not solve.

When clicked on the search button, i am preparing my Predicates and search my database, and show the data on tableview.

There are about 18000 entries on my database and when searching some words, the application is getting locked for a while, after the proccess end application shows my tableview as i want.

I want to put an activity indicator or something like that while this long progress is being done but i cant, because the application is being locked in that time.

What can i do in this case? I could not find any solution.

Thanks for your helps.

Regards.

A: 

you should start search in a new thread. while the main thread will show your indicator view (you can do visual stuff only in a main thread).

//make UIIndicatorView visible and start a new thread

[NSThread detachNewThreadSelector:@selector(doSearch) toTarget:self withObject:nil];

-(void) doSearch{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//do search stuff;
....
// tell your main thread that search is done
[self performSelectorOnMainThread:@selector(searchDone) withObject:nil waitUntilDone:NO];
[pool release]; }
-(void) searchDone{ //hide UIIndicator view
}
Kate