Swift模型无法从表格单元格更新

时间:2015-05-04 17:47:36

标签: ios swift

我有一个tableviewcontoller,它检索数据并存储在模型对象中。模型对象分配给表格单元格。当我在表格单元格文本框中进行更改时,更改不会更新为模型。这段代码有什么问题吗?如果这不是正确的方法,请告诉我们如何在表格行中进行更改。

 class myTable: UITableViewController , UITableViewDelegate, UITableViewDataSource{

 var models = [Customer]()

override func viewDidLoad() {
    super.viewDidLoad()

     self.generateUpdateModels()

    self.tableView.dataSource = self
    self.tableView.delegate = self
} 

override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    return false
}

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return models.count

}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("rowIdentifier", forIndexPath: indexPath) as! TextInputLabelTableViewCell

        cell.first.text = models[indexPath.row].first //label
        cell.last.text = models[indexPath.row].last   //label 
        cell.status.text = models[indexPath.row].status //textbox

    return cell
}

func generateUpdateModels(){
  //update models[]
}

@IBAction func done(sender: AnyObject) {

    //look into models for changes....
    // don't see the changes
    self.performSegueWithIdentifier("final", sender: self)

}

0 个答案:

没有答案