【问题标题】:Magical Record & SQLCipher for iOS - NSPersistentStore creation returns niliOS 的 Magical Record 和 SQLCipher - NSPersistentStore 创建返回 nil
【发布时间】:2013-10-30 15:39:51
【问题描述】:

我正在尝试将 SQLCipher 添加到使用 Magical Record 库的 iOS 项目中以加密数据库。还使用来自 encrypted-core-data 项目的 EncryptedStore 类:https://github.com/project-imas/encrypted-core-data

已按照帖子iOS Magical Record & SQLCipher中的说明进行操作

我已将方法 - (NSPersistentStore *) MR_addSqliteStoreNamed:(id)storeFileName withOptions:(__autoreleasing NSDictionary *)options 编辑为..

[coordinator
                                    addPersistentStoreWithType:EncryptedStoreType
                                    configuration:nil
                                    URL:databaseURL
                                    options:options
                                    error:&error];

有选项:

NSDictionary *options = @{
                            EncryptedStorePassphraseKey : @"the_password",
                            NSMigratePersistentStoresAutomaticallyOption : @YES,
                            NSInferMappingModelAutomaticallyOption : @YES
                            };

如果使用 EncryptedStoreType 类型,我有一个问题,即未创建结果 NSPersistentStore* 对象(返回 nil)。返回的错误代码也为零。

使用的 SQLCipher 库是商业 iOS 版本,其中已包含 openSSL。 SQLCipher 的集成似乎没问题,我在 encrypted-core-data 项目中测试时可以很好地使用加密数据库。

可能很长,但是在将 SQLCipher 与 Magical Record 集成时是否有人遇到过类似的问题 - 任何建议表示赞赏。

提前致谢 2J

【问题讨论】:

    标签: ios encryption sqlcipher


    【解决方案1】:

    我今天遇到了这个问题,在使用日志语句对 EncryptedStore.m 进行了多次探索之后,我发现它无法创建新数据库,因为我添加了一个带有索引作为属性名称的实体。

    原来你不允许使用 index 作为属性名。

    我在 EncryptedStore.m 中的 loadMetadata: 函数中发现了我的问题,所以如果你还没有解决它,可以从那里开始。

    【讨论】:

    • 太棒了 - 谢谢 TheJoe。如果将来对其他人有帮助,请让我添加到该列表中。您也不能拥有名为“id”的属性或名为“Transaction”的实体。
    • 我希望我能在 3 小时前找到这个答案,因为我有一个名为“交易”的实体。顺便说一句,您可以将其称为“Transaction_”。谢谢!
    • 我遇到了与order 相同的问题!您可以在此处找到完整列表:sqlite.org/lang_keywords.html
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-27
    • 1970-01-01
    • 2014-04-20
    • 1970-01-01
    相关资源
    最近更新 更多