我与coredata..I工作已采取coredata选项checked..so导航基于应用程序在我的第一页将是一个默认的tableview控制器,I addded的添加按钮,打开另一个表视图,我把它叫做我写信给在加barbutton“anothertableviewcpntroller” 的代码如下终止应用程序由于未捕获的异常“NSInternalInconsistencyException”
- (void)insertNewObject {
DetailsTable *details = [[DetailsTable alloc] initWithNibName:@"DetailsTable" bundle:[NSBundle mainBundle]];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController: details];
[self.navigationController presentModalViewController:navController animated:YES];
[details release];
}
然后,它会打开它,我有一些假名字填充它的表视图,当我的第一个单元格单击它打开另一个角度来审视所谓detailviewcontroller
, 写在细胞中的点击代码如下
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
*/
if(indexPath.row == 0)
{
AddRecipeViewController *addRecipeView = [[AddRecipeViewController alloc] initWithNibName:@"AddRecipeViewController" bundle:[NSBundle mainBundle]];
Recipes *recipes = (Recipes *)[NSEntityDescription insertNewObjectForEntityForName:@"Recipes" inManagedObjectContext:self.managedObjectContext];
addRecipeView.recipes = recipes;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController: addRecipeView];
[self.navigationController presentModalViewController:navController animated:YES];
[addRecipeView release];
}
}
在这里我有一个文本字段,用户将增加他的名字,然后点击保存按钮,
的保存按钮低于
- (void)save {
recipes.recipeName = textFieldOne.text;
recipes.cookingTime = textFieldTwo.text;
NSLog(recipes.recipeName);
NSError *error = nil;
if (![recipes.managedObjectContext save:&error]) {
// Handle error
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
exit(-1); // Fail
}
[self dismissModalViewControllerAnimated:YES];
}
当他点击Save按钮的代码,数据应该出现在第一页的桌面视图控制器上,但它没有发生我得到上述错误..ie
由于unc终止应用程序例如'NSInternalInconsistencyException',原因:'+ entityForName:找不到实体名称的NSManagedObjectModel'配方'
有人可以帮助我。
我要做一个野生刺,也许一个对象,它是NSManagedObjectModel的一个子类不能找到名为“配方”的实体。只有你知道你在哪里/如何划分了NSManagedObjectModel,以及你在哪里/如何指定实体名称“Recipes”。 –
我可以知道为什么这个错误出现..我是新来的.. – Ranjit
嗨丹尼尔应该发送你我的项目? – Ranjit