I'm starting in coreData, and I have a doubt.
I have an App that reads data from a server, I parse the data, and get as NSDictionary of Objects.
To save the data to coreData, i do the following:
for (NSDictionary *activityData in arrayWithResult){
[CompanyActivity createActivityWithInfoFromServer:activityData inManagedObjectContext:self.managedObjectContext];
}
if (![self.managedObjectContext save:&error])
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
This reads about 300 records. The method 'createActivityWithInfoFromServer:' checks if there is any record with that name. If so, updates the data, if not, creates one.
The problem is that, while the "for" cycle is running, if i interact with the user interface, it stops saving in core data, sometimes, not always. Why?
If I take the SAVE inside the cycle, the problem disappears.
What should I do?
Thanks all,
RL