【发布时间】:2014-04-08 07:45:26
【问题描述】:
我有一个 CoreData 项目和 2 个实体,名称分别是 MainList 和 Football..
MainList 实体有 3 个属性;
列表名称; listFavoritePlayer 列表播放器值
足球实体有 2 个属性;
团队名称; teamBestPlayerValue
我从 AddFootball 视图控制器添加属性。喜欢;
addTeam.teamName = _txtTeamName.text;
addTeam.bestPlayerValue = _txtBestPlayer.text;
addMainList.listName = _txtListName.text;
addMainList.favoritePlayer = _txtFavoritePlayer.text;
addMainList.playerValue = _txtPlayerValue.text;
我从我的 tableviewcontroller 获取 MainList。
cell.textlabel.text = mainList.listName;
cell.detailTextLabel.text = mainList.playerValue;
暂时没问题。通过这种方式,我将球队属性保留在我的 Football 实体中,并且我可以使用 MainList 在我的 tableviewcontroller 中显示它们。
但是..这里有问题;
当我想使用此代码在我的 Add FootballViewController 中仅添加 FavoritePlayer 时。
addMainList.favoritePlayer = @"Messi";
MyTableView 单元格带有空白。因为我没有添加mainList.listName和mainList.playerValue。但我想添加没有 listName 和 playerValue 的 favoritePlayer 以便从另一个视图控制器获取。
我认为我需要一个 if else 语句或另一个想法。
如果 cell.textLabel.text = nil;不显示
或
如果选中行。列表名 = 无;不显示单元格。
或
如果在显示单元格之前为空或 nil,则删除它们。
我只想要 1 个属性,除了 listName 或 playerValue。
【问题讨论】:
标签: objective-c core-data uitableview nsfetchedresultscontroller