Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Controller for ToDo App
// ViewController.swift
// HelloToDoSwift
// Created by Chris Jungmann on 4/1/16.
// Copyright © 2016 Chris Jungmann. All rights reserved.
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var tableToDo: UITableView!
override func viewDidLoad() {
// Do any additional setup after loading the view, typically from a nib.
override func didReceiveMemoryWarning() {
// Dispose of any resources that can be recreated.
override func viewWillAppear(animated: Bool) {
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return taskModel.tasks.count
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "default")
cell.textLabel?.text = taskModel.tasks[indexPath.row].itemName
cell.detailTextLabel?.text = taskModel.tasks[indexPath.row].itemDesciption
return cell
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if (editingStyle == UITableViewCellEditingStyle.Delete) {
@IBAction func buttonAddStuff(sender: AnyObject) {
performSegueWithIdentifier("showAdd", sender: self)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.