I’m using xCode 4.3.2. In this project, When i call ‘reloadXMLdata’ with button click, its not showing the activityIndicator, by the time of loading it looks like ‘hanged’, after few seconds it filling the data. How can i show activityIndicator by the time of loading?
Could you please help me for fixing this?
-(void)loadXML
{
NSString *urlAddress = [NSString stringWithFormat:@"my_xml_url"];
NSURL *url = [NSURL URLWithString:urlAddress];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
[xmlParser setDelegate:self];
BOOL success = [xmlParser parse];
if(success)
{
[self.activityIndicator setHidden:TRUE];
[self.activityIndicator stopAnimating];
[dataTable reloadData];
}
else
NSLog(@"Error!!!");
}
-(IBAction)reloadXMLdata:(id) sender
{
[self.activityIndicator setHidden:FALSE];
[self.activityIndicator startAnimating];
[self loadXML];
}
The problem is that you block the UI when calling
loadXMLand the activity indicator doesn’t have the opportunity to be displayed. So try using GCD like this: