ios – 如何使用MagicalRecord设置Core Data轻量级迁移?

ios – 如何使用MagicalRecord设置Core Data轻量级迁移?,第1张

概述我试图使用MagicalRecord设置Core Data的轻量级迁移.我使用Google和SO查看了有关此主题的所有帖子.我理解persistentStoreCoordinator如何工作以及我想要做的设置也是如此. 这是我的代码: AppDeligate.h NSPersistentStoreCoordinator *persistentStoreCoordinator; AppDelegat 我试图使用MagicalRecord设置Core Data的轻量级迁移.我使用Google和SO查看了有关此主题的所有帖子.我理解persistentStoreCoordinator如何工作以及我想要做的设置也是如此.

这是我的代码:@H_404_3@

AppDeligate.h@H_404_3@

NSPersistentStoreCoordinator *persistentStoreCoordinator;

AppDelegate.m@H_404_3@

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {if (persistentStoreCoordinator != nil) {    return persistentStoreCoordinator;}NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationdocumentsDirectory] stringByAppendingPathComponent: @"saori.sqlite"]];// handle db upgradeNSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:                         [NSNumber numberWithBool:YES],NSMigratePersistentStoresautomaticallyOption,[NSNumber numberWithBool:YES],NSInferMapPingModelautomaticallyOption,nil];NSError *error = nil;persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedobjectModel: [self managedobjectModel]];if (![persistentStoreCoordinator addPersistentStoreWithType:NSsqliteStoreType configuration:nil URL:storeUrl options:options error:&error]) {    // Handle error}return persistentStoreCoordinator;

}@H_404_3@

我得到以下错误,我理解;我不知道的是这些对象在哪里(我在我的应用程序中查找,并没有找到任何内容):@H_404_3@

No visible @interface for ‘AppDelegate’ declares the selector ‘applicationdocumentsDirectory’ and@H_404_3@

No visible @interface for ‘AppDelegate’ declares the selector ‘managedobjectModel’@H_404_3@

我已经创建了商店:@H_404_3@

大多数,如果不是所有我看过的代码都是相似的;我不知道MagicalRecord是否会为我处理这个问题,因为我找不到任何可以指示如何使用MR执行此 *** 作的文档.我的问题是:我需要做些什么来完成这项工作?@H_404_3@解决方法 MagicalRecord的重点在于为您管理:

[MagicalRecord setupCoreDataStackWithautoMigratingsqliteStorenamed:####];

查看有关Core Data堆栈设置here的文档.@H_404_3@ 总结

以上是内存溢出为你收集整理的ios – 如何使用MagicalRecord设置Core Data轻量级迁移?全部内容,希望文章能够帮你解决ios – 如何使用MagicalRecord设置Core Data轻量级迁移?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1099282.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存