Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Controller to add an item in Swift
// AddStuffVC.swift
// HelloToDoSwift
// Created by Chris Jungmann on 4/1/16.
// Copyright © 2016 Chris Jungmann. All rights reserved.
import UIKit
class AddStuffVC: UIViewController, UITextFieldDelegate {
@IBOutlet weak var textName: UITextField!
@IBOutlet weak var textDescription: UITextField!
override func viewDidLoad() {
// Do any additional setup after loading the view.
override func didReceiveMemoryWarning() {
// Dispose of any resources that can be recreated.
func textFieldShouldReturn(textField: UITextField) -> Bool {
return true
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
@IBAction func buttonAddTouch(sender: UIButton) {
// taskModel.addTask(textName.text!, desc: textDescription.text!)
taskModel.addTask(textName.text!, description: textDescription.text!)
textName.text = ""
textDescription.text = ""
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
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.