I have an iPhone/iPad app which uses Core Data.
In my DB I have only one table, though it's a very large one (about 40 columns). When i build the DB i create and insert about 13,000 new entities, and then I call 'saveContext'.
for (NSArray *singleDiamond in allDiamonds)
{
@try
{
if (//Some validation)
{
Diamond *diamond = [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass([Diamond class])
inManagedObjectContext:self.managedObjectContext];
//Do setup for diamond...
}
}
@catch (NSException *exception) {NSLog(@"%@",[exception message]);}
}
NSLog(@"Start Saving Context...");
[self saveContext];
NSLog(@"End Saving Context...");
My problem id that only the 'saveContext' method, takes 23 seconds to execute. That's not acceptable.
Is there something I do wrong? How can I improve the performance here?