У меня есть 2 объекта в моей структуре CoreData
, между ними существует связь «один ко многим». В основном объекте у меня есть NSOrderdSet, каждый раз, когда я делаю новое сохранение, я хочу добавить и сохранить второй объект в NSOrderdSet, но я получаю сообщение об ошибке. Вот мой код:Ошибка добавления NSEntity в NSOrderedSet
//main Entity
class Project : NSManagedObject {
func requestAddNewWeek (value: WeekContent) {
let mutableCopyOfSet = projectContent?.mutableCopy() as! NSMutableOrderdSet
mutableCopyOfSet.addObject(value)
projectContent = mutableCopyOfSet.copy() as ? NSOderedSet
}
}
// ViewController where the save occurs
class SetupWeekViewController {
var project : Project?
@IBAction func saveButton (sender : AnyObject) {
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let managedContext : NSManagedObjectContext = appDelegate.managedObjectContext
let entity = NSEntityDescription.entityForName("Content", inManagedObjectContext:managedObjectContext
//Here is where the error happens
project!requestAddNewWeek(newWeek)
managedContext.save()
}
// Здесь ошибка я получаю
2015-12-08 11:07:13.392 MySightwords[1998:189666] CoreData: error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///Users/Len/Library/Developer/CoreSimulator/Devices/0215DFE7-14EA-459F-991C-5ABF8020712D/data/Containers/Data/Application/7A509174-D568-4CCE-8A3D-9710FF80A9BF/Documents/SingleViewCoreData.sqlite options:(null) ... returned error Error Domain=NSCocoaErrorDomain Code=134100 "(null)" UserInfo={metadata={
NSPersistenceFrameworkVersion = 640;
NSStoreModelVersionHashes = {
Content = <16a6b5d3 e57d053c f85d1afa 2efe7c04 8da974e7 127f2c6b 847ea2f0 b63d732f>;
Project = <97588fff 696dabc6 896ec617 564b473f f3bc9bdc e6c891b3 84519149 9319c454>;
Sightwords = <6bf96219 adc3369d 4eec0597 b40472c3 d3af6a61 3d17bd5d 117885f4 509ecd2e>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "270A2DB1-BFDA-41A3-B044-DFBA717A1BDD";
"_NSAutoVacuumLevel" = 2;
}, reason=The model used to open the store is incompatible with the one used to create the store} with userInfo dictionary {
metadata = {
NSPersistenceFrameworkVersion = 640;
NSStoreModelVersionHashes = {
Content = <16a6b5d3 e57d053c f85d1afa 2efe7c04 8da974e7 127f2c6b 847ea2f0 b63d732f>;
Project = <97588fff 696dabc6 896ec617 564b473f f3bc9bdc e6c891b3 84519149 9319c454>;
Sightwords = <6bf96219 adc3369d 4eec0597 b40472c3 d3af6a61 3d17bd5d 117885f4 509ecd2e>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "270A2DB1-BFDA-41A3-B044-DFBA717A1BDD";
"_NSAutoVacuumLevel" = 2;
};
reason = "The model used to open the store is incompatible with the one used to create the store";
}
2015-12-08 11:07:13.396 MySightwords[1998:189666] Unresolved error Error Domain=YOUR_ERROR_DOMAIN Code=9999 "Failed to initialize the application's saved data" UserInfo={NSLocalizedDescription=Failed to initialize the application's saved data, NSLocalizedFailureReason=There was an error creating or loading the application's saved data., NSUnderlyingError=0x7ff7025e9200 {Error Domain=NSCocoaErrorDomain Code=134100 "(null)" UserInfo={metadata={
NSPersistenceFrameworkVersion = 640;
NSStoreModelVersionHashes = {
Content = <16a6b5d3 e57d053c f85d1afa 2efe7c04 8da974e7 127f2c6b 847ea2f0 b63d732f>;
Project = <97588fff 696dabc6 896ec617 564b473f f3bc9bdc e6c891b3 84519149 9319c454>;
Sightwords = <6bf96219 adc3369d 4eec0597 b40472c3 d3af6a61 3d17bd5d 117885f4 509ecd2e>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "270A2DB1-BFDA-41A3-B044-DFBA717A1BDD";
"_NSAutoVacuumLevel" = 2;
}, reason=The model used to open the store is incompatible with the one used to create the store}}}, [NSLocalizedDescription: Failed to initialize the application's saved data, NSLocalizedFailureReason: There was an error creating or loading the application's saved data., NSUnderlyingError: Error Domain=NSCocoaErrorDomain Code=134100 "(null)" UserInfo={metadata={
NSPersistenceFrameworkVersion = 640;
NSStoreModelVersionHashes = {
Content = <16a6b5d3 e57d053c f85d1afa 2efe7c04 8da974e7 127f2c6b 847ea2f0 b63d732f>;
Project = <97588fff 696dabc6 896ec617 564b473f f3bc9bdc e6c891b3 84519149 9319c454>;
Sightwords = <6bf96219 adc3369d 4eec0597 b40472c3 d3af6a61 3d17bd5d 117885f4 509ecd2e>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "270A2DB1-BFDA-41A3-B044-DFBA717A1BDD";
"_NSAutoVacuumLevel" = 2;
}, reason=The model used to open the store is incompatible with the one used to create the store}]
(lldb)
Может ли показать мне ошибку –
Хорошо, я добавил ошибку, которую я получаю, ее немного длинный –
Вы используете приложение в симуляторе? –