添加新实体时的Swift错误(核心数据)

Ste*_*vik 2 core-data swift

我刚刚用Core Data创建了一个新的xcode项目(Master-datail应用程序).在我创建了一个新实体(没有代码添加到控制器中)后,我试图在iOS模拟器上打开应用程序,我收到了这个错误

2015-03-27 17:59:20.882 Blog Reader [2677:301117] CoreData:错误:-addPersistentStoreWithType:SQLite配置:(null)URL:file:/// Users/stevik/Library/Developer/CoreSimulator/Devices/29A6C356 -8AFA-48BA-B0C0-B6031D760ECE/data/Containers/Data/Application/88603D30-BAED-4F1A-95AB-ADD87C3A469B/Documents/Blog_Reader.sqlite options:(null)...返回错误Error Domain = NSCocoaErrorDomain Code = 134100"操作无法完成.(Cocoa error 134100.)"UserInfo = 0x78f4edd0 {metadata = {NSPersistenceFrameworkVersion = 519; NSStoreModelVersionHashes = {Event = <5431c046 d30e7f32 c2cc8099 58add1e7 579ad104 a3aa8fc4 846e97d7 af01cc79>; }; NSStoreModelVersionHashesVersion = 3; NSStoreModelVersionIdentifiers =(""); NSStoreType = SQLite; NSStoreUUID ="25DE15EE-E903-4544-888B-7326455CF4B3"; "_NSAutoVacuumLevel"= 2; },reason =用于打开商店的模型与用于创建商店的模型不兼容,使用userInfo字典{metadata = {NSPersistenceFrameworkVersion = 519; NSStoreModelVersionHashes = {Event = <5431c046 d30e7f32 c2cc8099 58add1e7 579ad104 a3aa8fc4 846e97d7 af01cc79>; }; NSStoreModelVersionHashesVersion = 3; NSStoreModelVersionIdentifiers =(""); NSStoreType = SQLite; NSStoreUUID ="25DE15EE-E903-4544-888B-7326455CF4B3"; "_NSAutoVacuumLevel"= 2; }; reason ="用于打开商店的模型与用于创建商店的模型不兼容"; 2015-03-27 17:59:20.885 Blog Reader [2677:301117]未解决的错误可选(错误域= YOUR_ERROR_DOMAIN代码= 9999"无法初始化应用程序的已保存数据"UserInfo = 0x78ea27b0 {NSLocalizedDescription =无法初始化应用程序保存data,NSUnderlyingError = 0x78f4edf0"操作无法完成.(Cocoa error 134100.)",NSLocalizedFailureReason =创建或加载应用程序保存的数据时出错.}),可选([NSLocalizedDescription:无法初始化应用程序的保存数据,NSUnderlyingError:错误域= NSCocoaErrorDomain代码= 134100"操作无法完成.(可可错误134100)."UserInfo = 0x78f4edd0 {metadata = {NSPersistenceFrameworkVersion = 519; NSStoreModelVersionHashes = {Event = <5431c046 d30e7f32 c2cc8099 58add1e7 579ad104 a3aa8fc4 846e97d7 af01cc79>;}; NSStoreModelVersionHashesVersion = 3; NSStoreModelVersionIdentifiers =(""); NSStoreType = SQLite; NSStoreUUID ="25DE15EE-E903-4544-888B-7326455CF4B3" ; "_NSAutoVacuumLevel"= 2; },reason =用于打开商店的模型与用于创建商店的模型不兼容},NSLocalizedFailureReason:创建或加载应用程序保存的数据时出错.])

Tom*_*ton 7

除非实现模型迁移,否则无法更改Core Data模型并继续使用相同的持久性存储文件.Apple 就此提供了大量文档.但是,在应用程序开发期间,您通常只需从设备/模拟器中删除应用程序并安装新副本.这会删除任何现有数据,但在处理模型时通常没有问题.