Ios 非常奇怪的核心数据错误
我正在构建一个食谱应用程序,它用图像和标题保存食谱。标题字符串和图像一样可以很好地保存,但是当我从核心数据中提取标题时,标签文本就会这样显示 它在核心数据中保存为字符串,下面是我保存和检索它的方法 拯救 取回Ios 非常奇怪的核心数据错误,ios,string,core-data,indexing,nsentitydescription,Ios,String,Core Data,Indexing,Nsentitydescription,我正在构建一个食谱应用程序,它用图像和标题保存食谱。标题字符串和图像一样可以很好地保存,但是当我从核心数据中提取标题时,标签文本就会这样显示 它在核心数据中保存为字符串,下面是我保存和检索它的方法 拯救 取回 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { TableViewCell *cell = [tableView deque
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
Recipe *recipe = [RecipeController sharedInstance].recipes[indexPath.section];
cell.recipeImageView.image = [UIImage imageWithData:recipe.picture];
cell.descriptionLabel.text = recipe.description;
cell.titleLabel.text = recipe.title;
return cell;
}
问题二
这才刚刚开始发生,并在一段时间内工作正常,但在细节VC中,当我用不同的标题保存第二个条目时,它只是用始终存在的相同条目填充表视图(它在表视图上重复)。。。然而,当我选择它时,VC的细节会用正确的条目更新
然而,当我删除第一个时,它显示了以前的正确条目
下面是我更新VC详细信息并获得正确条目的代码
- (void)updateWithRecipe:(Recipe *)recipe {
self.recipe = recipe;
self.imageView.image = [UIImage imageWithData:recipe.picture];
self.titleField.text = recipe.title;
self.descriptionField.text = recipe.description;
}
VC中的segue方法。。。(这是可行的,传递正确的条目,但它不会以这种方式显示在表视图中)
我已经从手机上删除了应用程序并再次运行,但这种情况一直发生吗?任何帮助都将不胜感激
description
是由NSObject
提供的一种方法,用于对对象进行描述。不要给核心数据字段起相同的名字。编辑应该警告你这一点。哪个字段是addRecipeWithTitle:description:…
实际存储该参数?好的,这是有意义的,我修复了该错误,但另一个呢?谢谢你的帮助!您是否能够添加足够的项,以便进行大的滚动来区分单元缓存错误和核心数据对象标识错误?
- (void)updateWithRecipe:(Recipe *)recipe {
self.recipe = recipe;
self.imageView.image = [UIImage imageWithData:recipe.picture];
self.titleField.text = recipe.title;
self.descriptionField.text = recipe.description;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
DetailViewController *detailViewController = [DetailViewController new];
detailViewController.recipe = [RecipeController sharedInstance].recipes[indexPath.row];
[self.navigationController pushViewController:detailViewController animated:YES];
}