【问题标题】:MagicalRecord not saving?MagicalRecord没有保存?
【发布时间】:2012-11-19 21:29:14
【问题描述】:
// Setup magical record
[MagicalRecord setupCoreDataStack];

NSLog(@"Groups at startup: %d", [Group findAll].count);

[Group createEntity];
[[NSManagedObjectContext defaultContext] save];

我已将这段代码放在我的 AppDelegate 中。每次启动应用程序时,我都会看到计数为 0。我错过了什么?

【问题讨论】:

    标签: ios magicalrecord


    【解决方案1】:

    根据 MagicalRecord 的 github 页面..

    MagicalRecord 提供后台保存队列,以便保存所有 数据在后台的主线程中执行。这表示 可能需要使用 MR_saveNestedContexts 而不是 典型的 MR_save 方法,以便将您的更改一直保存到 您的永久存储;

    【讨论】:

    • 已弃用。我们用什么? MR_saveToPersistentStoreAndWait?
    猜你喜欢
    • 1970-01-01
    • 2017-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-25
    • 1970-01-01
    • 2013-03-11
    • 1970-01-01
    相关资源
    最近更新 更多