【发布时间】:2013-08-30 10:23:59
【问题描述】:
我已尝试使用以下代码更新核心数据中的对象,但出现错误。
NSError *error;
NSArray *objects = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
NSLog(@"objects %@",objects);
// yourIdentifyingQualifier is unique. It just grabs the first object in the array.
AllChallenge *tempChallenge = [[managedObjectContext executeFetchRequest:fetchRequest error:&error] objectAtIndex:0];
tempChallenge =[[AllChallenge alloc] init];
NSLog(@"tempchallenge >>>>> %@",tempChallenge);
// update the object
tempChallenge.status = 1;
[self.managedObjectContext save:&error];
编译后我得到CoreData:错误:无法调用NSManagedObject类'AllChallenge'上的指定初始化程序。谢谢你的帮助。
【问题讨论】:
-
objAllChallenge来自哪里?你的意思是写tempChallenge? -
是的,我的意思是 tempChallenge。
-
问题是您是否在代码中使用 tempChallenge 或 objAllChallenge。不在问题中。