-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathTaskDetailViewController.swift
44 lines (34 loc) · 1.02 KB
/
TaskDetailViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// TaskDetailViewController.swift
// TaskApplication
//
// Created by Michael Crump
// Copyright (c) 2015 Michael Crump. All rights reserved.
//
import UIKit
class TaskDetailViewController: UIViewController, UITextFieldDelegate {
@IBOutlet var txtTask: UITextField!
@IBOutlet var txtDesc: UITextField!
//Button Clicked
@IBAction func btnAddTask(sender : UIButton){
if (txtTask.text == ""){
// Task Title is blank, do not add a record
} else {
// add record
let name: String = txtTask.text!
let description: String = txtDesc.text!
taskMgr.addTask(name: name, desc: description, isDone: false)
// dismiss keyboard and reset fields
self.view.endEditing(true)
txtTask.text = nil
txtDesc.text = nil
}
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool{
textField.resignFirstResponder()
return true
}
}