Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @IBOutlet weak var table: UITableView!
- @IBOutlet weak var addItemBtnOutlet: UIButton!
- @IBOutlet weak var addItemTextField: UITextField!
- @IBAction func addItem(_ sender: Any) {
- if let textFieldInput = addItemTextField.text {
- items.addItem(text: textFieldInput)
- print(textFieldInput)
- addItemTextField.text = ""
- table.reloadData()
- }
- }
- // Return the number of rows for the table.
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- //returns number of items in Array
- return items.itemArray.count
- }
- // Provide a cell object for each row.
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let itemString = items.itemArray[indexPath.row]
- // Fetch a cell of the appropriate type.
- let cell = tableView.dequeueReusableCell(withIdentifier: "TextInputCell", for: indexPath) as! TextInputTableViewCell
- // Configure the cell’s contents.
- //cell.clipsToBounds = true
- cell.configure(text: itemString, placeholder: "")
- return cell
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement