MagicalRecord Insert太慢了

时间:2012-07-10 19:34:30

标签: objective-c xcode nsmanagedobject magicalrecord

我使用MagicalRecord并且必须立即在我的数据库中插入几个(比如大约50个)记录。这大约需要3秒钟。这些插件是正常的时间吗?我可以加快速度吗?我也想知道为什么我在后台和主线程中得到一个保存语句......

保存每个元素我得到这个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 ***

上下文是默认值:

NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];    

插入代码如下所示:

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

1 个答案:

答案 0 :(得分:6)

好的,永远不要打电话

[context MR_save]

在循环-.-