iOS Magical Record & SQLCipher

主宰稳场 提交于 2019-12-12 08:12:09

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/18365375/ios-magical-record-sqlcipher

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!