Question

I use MagicalRecord and have to insert several (lets say about 50) records in my database at once. This takes about 3 seconds. Is the a normal time for these inserts? Can I make that faster? I am also wondering why I get one saving statement in background and on in main thread...

Saving each element I get this LOG:

2012-07-10 21:27:55.319 MyApp[9815:1b53] -[NSManagedObjectContext(MagicalSaves) MR_saveWithErrorCallback:](0x47f2e0) -> Saving <NSManagedObjectContext: 0x47f2e0>: ***   BACKGROUND SAVE *** Context 
2012-07-10 21:28:13.024 MyApp[9815:707] -[NSManagedObjectContext(MagicalSaves) MR_saveWithErrorCallback:](0x480310) -> Saving <NSManagedObjectContext: 0x480310>: *** DEFAULT *** Context *** MAIN THREAD ***

The context is the default one:

NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];    

the insert code looks like this:

theWord = [Word MR_createEntity];
theWord.text = aCard.word;
theWord.playCount = [NSNumber numberWithInt:0];
theWord.user = user;    
[context MR_save];
Was it helpful?

Solution

Okay, never call

[context MR_save]

in a loop -.-

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top