核心数据错误
当我在我的实体上添加autoLogin属性Utente的代码不工作,如果我删除此属性的代码工作,为什么? PS:我需要新的属性,有人可以帮我请:)核心数据错误
Unresolved error Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error 134100.)" UserInfo=0x10970aae0 {metadata={ NSPersistenceFrameworkVersion = 479; NSStoreModelVersionHashes = { Utente = ; }; NSStoreModelVersionHashesVersion = 3; NSStoreModelVersionIdentifiers = ( "" ); NSStoreType = SQLite; NSStoreUUID = "C879290E-F81B-4D22-B6FF-12F34B97820F"; "_NSAutoVacuumLevel" = 2; }, reason=The model used to open the store is incompatible with the one used to create the store}, { metadata = { NSPersistenceFrameworkVersion = 479; NSStoreModelVersionHashes = { Utente = ; }; NSStoreModelVersionHashesVersion = 3; NSStoreModelVersionIdentifiers = ( "" ); NSStoreType = SQLite; NSStoreUUID = "C879290E-F81B-4D22-B6FF-12F34B97820F"; "_NSAutoVacuumLevel" = 2; }; reason = "The model used to open the store is incompatible with the one used to create the store"; }
代码:
//caricamento DB
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = [appDelegate managedObjectContext]; //the error signal is here
NSEntityDescription *entityDesc = [NSEntityDescription entityForName:@"Utente" inManagedObjectContext:context];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entityDesc];
NSManagedObject *matches = nil;
NSError *error;
NSArray *objects = [context executeFetchRequest:request
error:&error];
if ([objects count] == 0)
{
NSLog(@"No Email save");
}
else
{
for (int i = 0; i < [objects count]; i++)
{
matches = objects[i];
//NSManagedObject *o = objects[i];
//[context deleteObject:o]; //cancella
//[context save:&error];
//email
NSLog(@"email salvata : %@",[matches valueForKey:@"email"]);
emailText.text=[matches valueForKey:@"email"];
//password
NSString * psw =[matches valueForKey:@"password"];
if (psw)
{
NSLog(@"password salvata : %@",[matches valueForKey:@"password"]);
passwordText.text=[matches valueForKey:@"password"];
//auto-login
NSString * psw =[matches valueForKey:@"autoLogin"];
if (psw)
{
[self login:self];
}
}
事实上,一旦你部署它集成了核心数据的应用程序,生成的模型被版本。
如果您需要为您的实体添加新属性,那么您需要通过选择菜单“编辑器 - >添加模型版本”创建新版本的CoreData模型,然后对您的实体进行更改。
如果你的修改是简单的(列删除,列相加......),CoreData可以处理没有太大的特定代码的轻量级迁移,但是你需要在你的项目中的CoreData的所有版本模型,以使iOS能够为现有商店执行迁移。
所有在苹果的文档,它可以在这里找到充分详细:https://developer.apple.com/library/ios/documentation/cocoa/Conceptual/CoreDataVersioning/Articles/Introduction.html
THX你交配:) – 2014-09-10 15:24:39
只是1个问题,怎么“菜单”XD? – 2014-09-10 15:25:29
添加了屏幕截图,当您编辑您的xcdatamodel文件时显示此菜单 – cdescours 2014-09-10 15:28:53
的[用于开实体店的模式是用来创建存储的一个不兼容]可能重复(HTTP://计算器.com/questions/8881453/the-model-used-to-open-the-store-is-incompatible-with-one-used-to-create-the) – 2014-09-10 15:09:21
好吧,我需要做的是正确的func ? – 2014-09-10 15:12:19