レルムファイルを暗号化する必要があります。アプリ起動時にこのようにします。レルムデータベースを暗号化してクラッシュする
- (void)encryptRealm {
// Generate 64 bytes of random data to serve as the encryption key
uint8_t buffer[64];
SecRandomCopyBytes(kSecRandomDefault, 64, buffer);
NSData *keyData = [[NSData alloc] initWithBytes:buffer length:sizeof(buffer)];
// Create a Realm Configuration object with the encryption key
RLMRealmConfiguration *configuration = [RLMRealmConfiguration defaultConfiguration];
configuration.encryptionKey = keyData;
// Attempt to open a Realm file with the encryption key
NSError *error = nil;
RLMRealm *realm = [RLMRealm realmWithConfiguration:configuration error:&error];
// If the encryption key was not accepted, the error will state that the database was invalid
if (error != nil) {
NSLog(@"%@", error.localizedDescription);
return;
}
}
このようにクラッシュします。私は何が起こるかは分かりません。どうすればいいですか? チュートリアルはこちらからです。
https://academy.realm.io/posts/tim-oliver-realm-cocoa-tutorial-on-encryption-with-realm/
2017年10月6日15:58:+ 0800 33.366167 2.0 [20770:6589296]アライブ: 「/ VAR *** によりキャッチされない例外 'RLMException'、理由にアプリを終了/mobile/Containers/Data/Application/FA128FC0-BB80-469E-8B05-6B7957AD04A1/Documents/default.realm: パスをレルムで開くことができません '/ var/mobile/Containers/Data/Application/FA128FC0-BB80- 469E-8B05-6B7957AD04A1/Documents/default.realm ': レルムファイルではありません。'
私はあなたが明らかに動作しません二つの異なる暗号化キーと同じファイルを再度開こうと想定しています。 2回目に同じ暗号化キーを使用する必要があります。 – EpicPandaForce