我有两个具有 int64_t 属性的核心数据模型。当我尝试为整数字段分配非零值时,其中一个工作正常,而另一个抛出 EXC_BAD_ACCESS。我已经阅读了重新创建 NSManagedObject 子类的答案,但我没有成功。损坏的类如下所示:
@interface NoteObject : NSManagedObject
@property (nonatomic) int64_t remoteID;
@property (nonatomic) int64_t remoteArticleID;
@property (strong, nonatomic) ArticleObject *article;
@property (strong, nonatomic) NSString *status;
@property (strong, nonatomic) NSString *token;
@property (strong, nonatomic) NSString *title;
@property (strong, nonatomic) NSString *noteContent;
@property (strong, nonatomic) NSDate *pubDate;
@property (strong, nonatomic) NSDate *modDate;
@end
@implementation NoteObject
@dynamic remoteID;
@dynamic remoteArticleID;
@dynamic article;
@dynamic status;
@dynamic token;
@dynamic title;
@dynamic noteContent;
@dynamic pubDate;
@dynamic modDate;
@end
违规行在此块中:
_noteObject = [NSEntityDescription insertNewObjectForEntityForName:@"Note" inManagedObjectContext:self.managedObjectContext];
_noteObject.remoteArticleID = 0; // this works
_noteObject.remoteArticleID = 1; // this crashes
真正让我难过的是,在另一个模型中,我有相同类型的相同字段,它们会毫无问题地接受非零值:
bookmarkObject = [NSEntityDescription insertNewObjectForEntityForName:@"Bookmark" inManagedObjectContext:self.managedObjectContext];
bookmarkObject.remoteArticleID = 0; // this works
bookmarkObject.remoteArticleID = 1; // this works, too
我的 .xcdatamodeld 文件中是否有任何可能导致此问题的内容?
编辑
我的数据模型如下所示: