NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(BackgroundMethod:) object:self];
UIActivityIndicatorView aivLoading = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorViewStyleWhiteLarger];
- (void)ButtonClickMethod: (id) sender
{
// Start our activity indicator spinning (assuming its already been declared and added as a
subview)
[aivLoading startAnimating];
// Create the call to the background method we want to run
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(BackgroundMethod:) object:self];
// Add the operation to the queue to start it running
NSOperationQueue opQueue = [[NSOperationQueue alloc] init];
[opQueue addOperation: operation];
}
- (void)BackgroundMethod: (id)sender
{
// *** Your code here ***
// Call our done method
[(ViewControllerName *)sender done];
}
- (void) DoneMethod
{
[aivLoading stopAnimating];
}