【发布时间】:2017-03-15 21:42:49
【问题描述】:
我在 Tapleviewcell 中使用 UIStepper,但我不知道如何在我的 CoreData 中保存步进值?
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell: StepperTableViewCell = tableView.dequeueReusableCell(withIdentifier: "cell") as! StepperTableViewCell
//stepper is your UIStepper reference from StepperTableViewCell
cell.stepper.tag = indexPath.row
cell.stepper.addTarget(self, action: #selector(stepperAction(sender:)), for: .valueChanged)
return cell
}
func stepperAction(sender: UIStepper) {
print("Stepper \(sender.tag) clicked. Its value \(sender.value)")
}
【问题讨论】:
-
你想做什么?只需保存 sender.value?你真的需要核心数据吗?也许 UserDefaults 也会很棒?对于核心数据,请查看此处raywenderlich.com/145809/getting-started-core-data-tutorial 或此处learnappdevelopment.com/ios-app-development-free/… 或此处medium.com/ios-geek-community/…
-
我在我的项目中使用 CoreData,步进器是其中的一部分。我知道如何将文本从 UITextfield 保存到 CoreData,但我不知道如何在 CoreData 中保存 IUStepper 值
-
无论如何我不明白这个问题。 sender.value 是双精度数或数字,不是吗? Core Data 支持双精度。以与字符串相同的方式保存它。见这里:stackoverflow.com/questions/37958530/using-double-in-core-data
-
我的 UIStepper 在 tableviewcell 中,我不知道如何保存刚刚点击的步进器,对不起我的语言。
标签: core-data swift3 uistepper