Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TodoTableViewController: UITableViewController {
- struct Todo {
- let description : String
- var isDone : Bool = false
- init(description:String) {
- self.description = description
- }
- }
- var todoList = [Todo]()
- func touchedAdd() {
- let alertController = UIAlertController(title: "ToDo", message: "할 일을 입력해 주세요.", preferredStyle: UIAlertControllerStyle.Alert)
- let cancelAction = UIAlertAction(title: "취소", style: UIAlertActionStyle.Cancel, handler:nil)
- let addAction = UIAlertAction(title: "추가", style: UIAlertActionStyle.Default, handler: { (alertAction) in
- if let text = alertController.textFields?.first?.text {
- if( text.characters.count>0 ){
- self.todoList.append(Todo(description: text))
- self.tableView.reloadData()
- }
- }
- })
- alertController.addTextFieldWithConfigurationHandler(nil)
- alertController.addAction(cancelAction)
- alertController.addAction(addAction)
- presentViewController(alertController, animated: true, completion: nil)
- }
- // 생략
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement