简体   繁体   中英

How to turn off automatic encryption for core data in iOS 5

I have a large core data store that I dont care about encryption. I am worried about the overhead of the automatic encryption so I am trying to disable it.

The quote from the docs is :

For applications built for iOS 5.0 or later, persistent stores now store data by default in an encrypted format on disk.

This is the code I am using, its not crashing, but im not 100% sure is doing anything. (I got the constant names from here ).

NSDictionary* optionsDictionary = [NSDictionary 
                                   dictionaryWithObject:NSFileProtectionNone 
                                   forKey:NSFileProtectionKey];

if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType 
                                   configuration:nil
                                   URL:storeURL
                                   options:optionsDictionary
                                   error:&error]) {
  • Is this the right code?

  • How can I tell if has stopped encryption?

Robert,

All encryption on iOS is performed in hardware. I, and the Apple engineers I've spoken with, would be really surprised if you saw any performance difference with an encrypted filesystem. (Flash on iOS devices is so slow that you will not see the encryption delays.)

As your above commenters suggest, use the simulator and the runtime system that shows you the SQL that is actually issued for your fetches to see what the performance differences between you two fetches actually are.

Andrew

According to the docs, that code should turn off all the file protection even on iOS5. You can't easily test it, however.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM