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.
来源:https://stackoverflow.com/questions/18365375/ios-magical-record-sqlcipher