我正在使用 Magical Record 来保存我的数据。这些数据需要加密,所以我尝试将其与 SQLCipher 库结合起来(http://sqlcipher.net/ios-tutorial/ http://sqlcipher.net/ios-tutorial/).
我已经设置了 SQLCipher 并使用本示例中的 EncryptedStore 文件成功地使用 Core Data 对其进行了测试https://github.com/project-imas/encrypted-core-data https://github.com/project-imas/encrypted-core-data:
我所做的只是改变 NSPersistentStoreCoordinator 像这样:
NSPersistentStoreCoordinator *coordinator = [EncryptedStore makeStore:[self ManagedObjectModel]:[SSKeychain passwordForService:myservice account:myaccount]];
所以我认为我需要更改 NSPersistentStoreCoordinator 在 MagicalRecord 中创建的方式,但我没有运气,所以任何帮助将不胜感激。
如果您已经有持久存储协调器,则在使用 MagicalRecord 时必须手动设置核心数据堆栈。我推荐一些类似的东西:
NSPersistentStoreCoordinator *coordinator = //how ever you do it;
[NSPersistentStoreCoordinator MR_setDefaultCoordinator:coordinator];
[NSManagedObjectContext MR_initializeDefaultContextWithCoordinator:coordinator];
您可能需要自己公开初始化方法。
作为旁注,您可能需要向 MagicalRecord 问题日志添加一个票证,以向设置方法集合中添加一个方法来指定您自己的协调器,以便由 MagicalRecord 本身来处理这项工作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)