我只是想把我的头脑集中在核心数据上。我已经设法在 applicationDidFinishLaunching 中加载了一些数据,但现在我想做一些更复杂的事情。当我从视图控制器 B 回到视图控制器 A 时,我想将配方名称从 B 发送回 A,然后将其写入核心数据。我收到此错误:
CoreData:错误:无法在 NSManagedObject 类“Recipe”2013-11-01 19:10:07.886 RecipesWithCore[96409:70b] -[Recipe setRecipeName:] 上调用指定初始化程序:无法识别的选择器发送到实例 0x8c8cf40 2013-11-01 19 :10:07.890 RecipesWithCore [96409:70b] *由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[Recipe setRecipeName:]:无法识别的选择器发送到实例0x8c8cf40'
这是我的 unwindToRecipes:
-(IBAction) unwindToRecipes:(UIStoryboardSegue *)segue{
DBKAddRecipeViewController *source = [segue sourceViewController];
NSString *rn = source.recipe.recipeName;
if (recipe != nil){
//Add the recipe to coredata
NSManagedObjectContext *context = [self managedObjectContext];
NSManagedObject *newRecipe = [NSEntityDescription
insertNewObjectForEntityForName:@"Recipe"
inManagedObjectContext:context];
[newRecipe setValue:rn forKey:@"recipeName"];
}
}