的错误我遇到了SQLCipher数据库加密和CoreData问题: 当我将持久性存储协调程序与SQLCipher配合使用时,它总是在第一个应用程序之后出现故障一对多关系重新启动。 因此,当我第一次启动应用程序时,我创建了具有关系的NSManagedObjects,然后,当我保存数据库并重新打开该应用程序时,当我尝试访问这些关系时崩溃。 没有SQLCipher一切工作正常。SQLCipher和CoreData问题:CoreData无法履行
这里是SQLCipher持久性存储初始化代码:
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (!_persistentStoreCoordinator) {
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"MyApp.sqlite"];
NSDictionary *options = @{EncryptedStorePassphraseKey: @"MyApp",
EncryptedStoreDatabaseLocation: storeURL};
NSError *error;
_persistentStoreCoordinator = [EncryptedStore makeStoreWithOptions:options managedObjectModel:[self managedObjectModel] error:&error];
if (error) {
NSLog(@"%@", error);
}
}
return _persistentStoreCoordinator;
}
代码,我创建NSManagedObject:
- (id)createObjectWithClassName:(NSString *)name
{
NSManagedObject *object = [[NSClassFromString(name) alloc] initWithEntity:[NSEntityDescription entityForName:name inManagedObjectContext:self.context] insertIntoManagedObjectContext:self.context];
return object;
}
创建托管对象的代码是什么样的? – 2014-12-05 17:43:05
@TomHarrington我使用NSManagedObject创建代码更新了帖子 – 2014-12-05 22:45:49
有用的链接:https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdTroubleshooting.html – Bhushan 2014-12-17 06:58:21