+(UIActivityIndicatorView*)addLoadingViewandTheViewToShowIn: (UIView *)viewToShowIn
{
UIActivityIndicatorView* activityIndicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[activityIndicator setCenter:viewToShowIn.center];
[activityIndicator startAnimating];
[viewToShowIn addSubview:activityIndicator];
[viewToShowIn bringSubviewToFront:activityIndicator];
return [activityIndicator autorelease];
}
+(void)removeLoadingView: (UIActivityIndicatorView *)activityIndicator
andTheViewToShowIn: (UIView *)viewToShowIn
{
[activityIndicator removeFromSuperview];
}
AND:
UIActivityIndicatorView* activityIndicator = [LoadingView addLoadingViewandTheViewToShowIn:self.view];
[ChooseSongDataSourse reloadArrayWithData:self.arrayPlaylist andReturn:^(NSString *resone) {
dispatch_async(dispatch_get_main_queue(), ^(){// you can remove it, if you sure that block performed in main-thread
[LoadingView removeLoadingView:activityIndicator andTheViewToShowIn:self.view];
});
}];
The main problem of yours code, that pointer at UIActivityIndicatorView wasn't returned from +(void)addLoadingView:andTheViewToShowIn:;
You can return objects from functions by return parameter or by pointer at pointer (like many functions that return NSError* by taking NSError** argument).