iOS Magical Record& SQLCipher [英] iOS Magical Record & SQLCipher

查看:134
本文介绍了iOS Magical Record& SQLCipher的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用魔法记录来保存我的数据。此数据需要加密,因此我尝试将其与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的方式,但我没有运气,所以任何帮助都会受到赞赏。

解决方案

如果您已经拥有持久性存储协调器,则必须在使用MagicalRecord时手动设置核心数据堆栈。我建议这些内容:

  NSPersistentStoreCoordinator * coordinator = //你怎么做的; 
[NSPersistentStoreCoordinator MR_setDefaultCoordinator:coordinator];
[NSManagedObjectContext MR_initializeDefaultContextWithCoordinator:coordinator];

您可能需要自己公开initialize方法。



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

I m using Magical Record for saving my data. This data needs encryption, so i m trying to combine it with SQLCipher library(http://sqlcipher.net/ios-tutorial/).

I already setup SQLCipher and tested it with Core Data successfully, using EncryptedStore file from this example https://github.com/project-imas/encrypted-core-data:

What i did was only changed NSPersistentStoreCoordinator like this:

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

So i think i need to change how NSPersistentStoreCoordinator is created in MagicalRecord, but i had no luck with it, so any help would be appreciated.

解决方案

If you already have a persistent store coordinator, you will have to setup the core data stack manually when using MagicalRecord. I recommend something along these lines:

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

You may need to expose the initialize method on your own.

As a side note, you may want to add a ticket to the MagicalRecord issues log to add a method to the setup method collection to specify your own coordinator so that this work is taken care of by MagicalRecord itself.

这篇关于iOS Magical Record& SQLCipher的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆