I am trying to monitor a thread that i set running in the background. I need to be alerted when it is finished executing.
- (IBAction) btnGreaterTen_clicked :(id)sender{
self.searchDistance = [NSNumber numberWithDouble : 10];
CGRect frame = CGRectMake (120.0, 185.0, 80, 80);
activity = [[UIActivityIndicatorView alloc] initWithFrame: frame];
activity.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
[navigationUpdateFromDetail.window addSubview: activity];
[activity startAnimating];
thread = [[NSThread alloc] init];
[thread start];
[self performSelectorInBackground: @selector (getSetDisplay) withObject:nil];
if(thread.isFinished == YES){
[activity stopAnimating];
}
}
The above code what i have after trying different set up in order to achieve the end result. I am trying to animate the UIActivityIndicator while I use that method "getSetDisplay" to grab information from the net.
The function is good, but the Activity indicator was not coming up. I was told that i needed to run the process on a background thread and the animation on the main thread. My problem now is how do I monitor for when this process is done to stop the activity indicator. thank you in advance