【问题标题】:abort method error when deleting model class删除模型类时中止方法错误
【发布时间】:2015-02-12 09:59:20
【问题描述】:

在我的简单项目中,我有一个核心数据模型文件,在这个模型文件中我有一个名为“Target”的实体,我为这个实体创建了一个 NSManagedObject 的子类,以便我可以保存数据。所以现在我有一个只有两个属性的.h.m 目标类文件:

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>


@interface Target : NSManagedObject

@property (nonatomic, retain) NSString * body;
@property (nonatomic, retain) NSDate * time;

@end

现在我想在这个类中添加 2 个更多属性,所以我阅读了它并尝试了一些技术,但每次都会给我同样的错误:

如何摆脱“开店的型号与开店的型号不兼容”的错误?

【问题讨论】:

标签: ios objective-c core-data nsmanagedobject


【解决方案1】:

尝试从模拟器/设备中删除您的应用程序。并尝试再次构建并运行它。

【讨论】:

    【解决方案2】:

    每当您修改实体(例如添加属性/删除/修改)时,您都需要从模拟器/设备中删除应用程序,然后您需要运行应用程序以避免崩溃。..

    否则,如果您的应用在 App Store 中,并且如果您想向现有应用添加更多属性,则需要进行核心数据迁移..

    参考以下链接

    http://www.informit.com/articles/article.aspx?p=2150667&seqNum=2

    http://code.tutsplus.com/tutorials/core-data-from-scratch-migrations--cms-21844

    https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmLightweightMigration.html

    https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/Introduction.html

    希望对你有帮助..

    【讨论】:

      【解决方案3】:

      尝试从您的模拟器/设备上卸载应用程序,然后重新安装。之所以会出现这种情况,是因为您在添加 NSPersistentStoreNSPersistentStoreCoordinator 对象时提供了哪种类型的迁移或存储选项。

      尝试阅读有关迁移的信息

      https://developer.apple.com/library/mac/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSPersistentStoreCoordinator_Class/index.html#//apple_ref/doc/constant_group/Migration_Options

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-03-03
        • 2015-10-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-12-05
        • 2020-12-24
        相关资源
        最近更新 更多