views:

639

answers:

1

I am trying to perform an operation on a background thread. In the past i have used

  [self performSelectorInBackground: @selector (getSetDisplay) withObject: nil];

to accomplish this. However, I have registered for this function to be executed within an NSNotification and I need to animate the UIActivityIndicator. The UIActivityIndicator (from what I understand) needs to run on the main thread, but this notification is doing that as well and is blocking it.

- (IBAction) btnRefresh_clicked :(id)sender{

[activity startAnimating];

[navigationUpdateFromDetail setUpdate: NO];

[navigationUpdateFromDetail.locationManager startUpdatingLocation];

[[NSNotificationCenter defaultCenter] addObserver: self selector : @selector   (getSetDiplay) name: @"LocationUpdated" object: nil];

}   

does anyone have an idea about how to get this running on a background thread? thanks is advance.

+1  A: 

Take a look at the NSObject method performSelectorOnMainThread:withObject:waitUntilDone: - it lets you run a method, like startAnimating, on the main thread while still keeping your currently executing method in the background.

Tim
thank you, that worked
Makinitez21