Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. class TodoTableViewController: UITableViewController {
  2.  
  3. struct Todo {
  4. let description : String
  5. var isDone : Bool = false
  6. init(description:String) {
  7. self.description = description
  8. }
  9. }
  10.  
  11. var todoList = [Todo]()
  12.  
  13. func touchedAdd() {
  14. let alertController = UIAlertController(title: "ToDo", message: "할 일을 입력해 주세요.", preferredStyle: UIAlertControllerStyle.Alert)
  15. let cancelAction = UIAlertAction(title: "취소", style: UIAlertActionStyle.Cancel, handler:nil)
  16. let addAction = UIAlertAction(title: "추가", style: UIAlertActionStyle.Default, handler: { (alertAction) in
  17. if let text = alertController.textFields?.first?.text {
  18. if( text.characters.count>0 ){
  19. self.todoList.append(Todo(description: text))
  20. self.tableView.reloadData()
  21. }
  22. }
  23. })
  24.  
  25. alertController.addTextFieldWithConfigurationHandler(nil)
  26. alertController.addAction(cancelAction)
  27. alertController.addAction(addAction)
  28.  
  29. presentViewController(alertController, animated: true, completion: nil)
  30. }
  31.  
  32. // 생략
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement