6

我正在使用 Magical Record 来保存我的数据。这些数据需要加密,所以我试图将它与 SQLCipher 库(http://sqlcipher.net/ios-tutorial/)结合起来。

我已经设置了 SQLCipher 并使用 Core Data 成功测试了它,使用此示例中的 EncryptedStore 文件https://github.com/project-imas/encrypted-core-data

我所做的只是像这样更改 NSPersistentStoreCoordinator :

NSPersistentStoreCoordinator *coordinator = [EncryptedStore makeStore:[self managedObjectModel]:[SSKeychain passwordForService:myservice account:myaccount]];

所以我认为我需要更改在 MagicalRecord 中创建 NSPersistentStoreCoordinator 的方式,但我没有运气,所以任何帮助将不胜感激。

4

1 回答 1

2

如果您已经有一个持久存储协调器,则在使用 MagicalRecord 时必须手动设置核心数据堆栈。我推荐一些类似的东西:

 NSPersistentStoreCoordinator *coordinator = //how ever you do it;
 [NSPersistentStoreCoordinator MR_setDefaultCoordinator:coordinator];
 [NSManagedObjectContext MR_initializeDefaultContextWithCoordinator:coordinator];

您可能需要自己公开初始化方法。

作为旁注,您可能希望向 MagicalRecord 问题日志添加票证,以向 setup 方法集合添加方法以指定您自己的协调器,以便由 MagicalRecord 本身处理这项工作。

于 2013-08-21T19:16:12.477 回答