ios - 我的核心数据模型出了什么问题?

标签 ios macos sqlite core-data

我是 CoreData 的新手,无法理解我的模型出了什么问题。当我尝试将持久存储添加到存储协调器时发生错误:

NSPersistentStore *persistentStore = [self.persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:error];

这是日志和错误:

> CoreData: sql: CREATE TABLE ZMANAGEDOBJECT ( Z_PK INTEGER PRIMARY KEY,
> Z_ENT INTEGER, Z_OPT INTEGER, ZSECTION.ARTICLES INTEGER, ZTITLE
> INTEGER, ZBOOK.AUTHOR INTEGER, ZNAME INTEGER, ZAUTHOR INTEGER,
> ZPUBLISHER INTEGER, ZSUBTITLE INTEGER, ZTITLE1 INTEGER, ZAUTHOR1
> INTEGER, ZTEXT INTEGER, ZTITLE2 INTEGER, Z_FOK_SECTION.ARTICLES
> INTEGER, ZCREATEDAT TIMESTAMP, ZUPDATEDAT TIMESTAMP, ZID_ VARCHAR,
> ZTYPE BLOB, ZCONTENT BLOB, ZATTRIBUTES BLOB, ZCOVER BLOB, ZIMAGE BLOB
> )

> CoreData: annotation: Disconnecting from sqlite database due to an
> error.

> CoreData: error: (1) I/O error for database at
> /Users/firuznarzikulov/Library/Application
> Support/BahaiAppAdmin/BahaiAppAdmin.sqlite

Error Domain=NSCocoaErrorDomain Code=256 "The file couldn’t be
opened." UserInfo={NSSQLiteErrorDomain=1, NSUnderlyingException=I/O
error for database at /Users/user/Library/Application
Support/App/database.sqlite. SQLite error code:1,
'near ".": syntax error'}

这是我的模型图: enter image description here

ManagedObject 是抽象实体,也是除 LocalizedString 之外的所有其他实体的父级。

感谢任何帮助和想法!

最佳答案

尝试重命名不带“.”的关系。

通常的模式是例如“authorName”表示一对一关系,“authorNames”表示一对多关系。

关于ios - 我的核心数据模型出了什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39356110/

相关文章:

iphone - masksToBounds 和 cornerRadius 之间的关系是什么?

iOS后台获取。获取 Firebase 数据库

html - 自定义滚动条,类似于 MacOS 上的默认滚动条

ubuntu - 使用自定义分隔符从文件导入 Sqlite?

ios - swift 3 : CAShapeLayer mask not animating for pie chart animation

ios - 将 iAd 横幅叠加到屏幕上而不是调整屏幕大小

qt - 在Mac OS下如何将最新版本的GCC(4.6)与Qt一起使用?

iphone - 在 Objective-C 中创建 View 委托(delegate)的语法

android - 无法在我的 Android 应用程序中创建 SQLite 数据库

python - 将列名写入文件