iOS Magical Record和SQLCipher

6 iphone ios sqlcipher magicalrecord

我使用魔法记录来保存我的数据.此数据需要加密,因此我尝试将其与SQLCipher库(http://sqlcipher.net/ios-tutorial/)结合使用.

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

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

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

所以我想我需要改变在MagicalRecord中创建NSPersistentStoreCoordinator的方式,但我没有运气,所以任何帮助都会受到赞赏.

cas*_*ora 2

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

 NSPersistentStoreCoordinator *coordinator = //how ever you do it;
 [NSPersistentStoreCoordinator MR_setDefaultCoordinator:coordinator];
 [NSManagedObjectContext MR_initializeDefaultContextWithCoordinator:coordinator];
Run Code Online (Sandbox Code Playgroud)

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

作为旁注,您可能需要向 MagicalRecord 问题日志添加一个票证,以向设置方法集合中添加一个方法来指定您自己的协调器,以便由 MagicalRecord 本身来处理这项工作。