如何将新数据保存到现有单元格?

时间:2017-05-30 06:09:26

标签: iphone swift core-data swift3 ios10

如何将时间保存到现有单元格?

第1页有姓名,电话号码,公司,工号......

由于时间在第2页,我不知道如何轻松保存。 有人可以帮我解决这个问题吗?非常感谢!!!!

NSLocalizedDescription=The operation couldn’t be completed. (Cocoa error 1570.), NSValidationErrorObject=<VisitorMO: 0x60000009c570> (entity: Visitor; id: 0x600000221800 <x-coredata:///Visitor/t47C35BF8-213C-4C00-9B86-DDF5B423B9092> ; data: {
    company = nil;
    jobnumber = nil;
    jobtype = nil;
    name = nil;
    phonenumber = nil;
    signintime = "May 30, 2017, 2:10:23 PM";
})}
)

enter image description here

1 个答案:

答案 0 :(得分:0)

看起来您想要更新现有单元格的数据..

你可以做点事......

首先 yourTableview.reloadData()调用此方法。

这将重新加载您的tableview。

第二,如果您想更新现有的单元格..

yourTableview.beginUpdates()
yourTableview.reloadRows(at: [indexPath], with: .automatic)
yourTableview.endUpdates()

此处indexPath将是您要更新的索引。

第三次更新特定单元格

let indexPathYouWantToUpdate = IndexPath(row:Any row which you want to update,section:0)

let cell = yourTableview.cellForRowAtIndex(at:indexPathYouWantToUpdate) as? YourCustomCell

cell?.value1 = 100
cell?.value2 = 200

以您希望的方式更新所有单元格值。

我希望这能解决你的问题。

相关问题