Hey there,
I have got an application, that is getting data via XML-files. During the parsing-part the data is written/inserted to the local sqlite3-database on the device. So, if the data is syncronized, there does a loading-screen appear (performed in background) and is telling the user, that the data is syncronized.
This is working quite well by the following code:
Loading-screen part:
[self.view performSelectorInBackground:@selector(addSubview:) withObject:self.updateView];
[self.view performSelectorInBackground:@selector(bringSubviewToFront:) withObject:self.updateView];
for (NSURL *url in urlArray)
{
// Set up a UILabel so the user can see which data is syncronized
[self.updateLabel performSelectorInBackground:@selector(setText:) withObject:[NSString stringWithFormat:@"%@",url]];
// Parsing part
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
// Setting the database-manager as delegate
[xmlParser setDelegate:self.datencontroller];
[xmlParser parse];
[xmlParser release];
[url release];
}
[self.updateView removeFromSuperview];
Now i got the following problem: obviously the parsing is blocking the operating App. Since I want to implement a cancel-method so the user is able to interrupt the syncronizing, I got a problem.
No action is noticed, until the parsing-part is done/finished. So it's quite useless to implement a button that is calling a cancel-method, if the button-pressing is not noticed by the app.
I tried several ways with performing in background etc. but I got the problem that the data manager is storing the data in one single database. So there is no way to access it simultaneously from two different ways and insert data.
Can anyone of you help me with this? Thanks in advance.