In the viewDidLoad method of my viewController I wrote something like this:
- (void)viewDidLoad {
[super viewDidLoad];
self.hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
self.hud.labelText = @"Loading";
[serverData loadNewsData:self ];
}
Basically I show the HUD and start a method loadNewsData on another class, passing the viewController.
The method in the other class is like this:
-(void)loadNewsData:(LoadViewController*) loadViewController
{
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:[siteAddress stringByAppendingString:getNewsList] parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
loadViewController.hud.detailsLabelText = @"updating news";
[NewsModel setNewsData:responseObject];
loadViewController.hud.detailsLabelText = @"Finished";
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
When the request of the AFHTTPRequestOperation starts I was expecting to see the sub menu in the HUD to change in "Updating news". But nothing happens. I just see Finished at the end of the process. The requests takes like 10sec so I was expecting to see "updating news", but nothing. I try also to this:
dispatch_async(dispatch_get_main_queue(), ^{
loadViewController.hud.detailsLabelText = @"updating news"; });
Thinking I have to be in the UI queue to update some UI stuff, but it did not work either. I'm a newbie probably I miss something.
thanks for any good advices.