A. G
A. G

Reputation: 961

How to clear fields after clicking save Swift 3

So, I have a tableview that looks something like this.

enter image description here

This is how it looks like with fields empty. After I click on the rows, I can select options and then it looks something like the second image. However, after I click save on this screen, I want all of these fields clear. I have tried code like this and placed it in my viewWillAppear tab. Since this view is accessed by a tab bar controller, viewDidLoad doesn't called, but it still doesn't work. Could someone please tell me how I would clear the fields after I click save.

enter image description here

  self.categoryDisplayed = ""
    self.collectionsDisplayed = ""
    self.currencyNameDisplayed = ""

    let indexpath = NSIndexPath(row: 0, section: 0)
    let cell = tableView.dequeueReusableCell(withIdentifier: "listCell", for: indexpath as IndexPath) as! ListDataTableViewCell


    if (!self.isMovingToParentViewController){
        self.categoryDisplayed = ""
        self.collectionsDisplayed = ""
        cell.optionSelectedLabel.text! = ""
    }

Upvotes: 0

Views: 101

Answers (1)

Leoog
Leoog

Reputation: 244

You can reload your data like this:

tableview.reloadData()

Upvotes: 1

Related Questions