通过获取核心数据字符串来填充 UITextField
Populate UITextField by fetching a Core Data string
我正在尝试使用所选单元格中的数据填充 UITextField
。当填充 table 时,我使用数组 var intentionsArray: [EIntentions] = []
,其中 EIntentions
是我在 Core Data 中的实体。每当我尝试将文本字段设置为数组中的特定索引路径值时,从 EIntentions
转换为 String
.
时出现错误
基本上,我现在想做的是使用给我的 indexPath 值从 Core Data 数据库中提取特定值。我找不到可靠的方法,想知道是否有任何建议。
我最终使用了这个,其中 selectedCellText
是我从另一个 .swift 文件中提取的全局变量
let selectedCellSet = intentionsArray[indexPath.row]
selectedCellText = selectedCellSet.value(forKey: "eIntentionCell") as? String)!
我正在尝试使用所选单元格中的数据填充 UITextField
。当填充 table 时,我使用数组 var intentionsArray: [EIntentions] = []
,其中 EIntentions
是我在 Core Data 中的实体。每当我尝试将文本字段设置为数组中的特定索引路径值时,从 EIntentions
转换为 String
.
基本上,我现在想做的是使用给我的 indexPath 值从 Core Data 数据库中提取特定值。我找不到可靠的方法,想知道是否有任何建议。
我最终使用了这个,其中 selectedCellText
是我从另一个 .swift 文件中提取的全局变量
let selectedCellSet = intentionsArray[indexPath.row]
selectedCellText = selectedCellSet.value(forKey: "eIntentionCell") as? String)!