Rename ViewController -> MachineViewController
This commit is contained in:
parent
358c67cdfb
commit
c96c0bd0fc
2 changed files with 46 additions and 25 deletions
|
@ -14,8 +14,54 @@ class MachineViewController: UIViewController, UITextFieldDelegate {
|
|||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
inputTextField.delegate = self
|
||||
//outputTextField.delegate = self
|
||||
}
|
||||
|
||||
// MARK: - UITextFieldDelegate
|
||||
|
||||
func textFieldDidEndEditing(textField: UITextField) {
|
||||
print("textFieldDidEndEditing")
|
||||
}
|
||||
|
||||
func textFieldShouldBeginEditing(textField: UITextField) -> Bool {
|
||||
print("textFieldShouldBeginEditing")
|
||||
return true
|
||||
}
|
||||
|
||||
func textFieldShouldEndEditing(textField: UITextField) -> Bool {
|
||||
print("textFieldShouldEndEditing")
|
||||
return true
|
||||
}
|
||||
|
||||
func textFieldShouldReturn(textField: UITextField) -> Bool {
|
||||
if textField === inputTextField {
|
||||
var machine: Machine! = nil
|
||||
do {
|
||||
machine = Machine(rotors: [try Rotor(.EnigmaI), try Rotor(.EnigmaII), try Rotor(.EnigmaIII)], reflector: try Reflector(.EnigmaB), plugboard: Plugboard())
|
||||
} catch let error {
|
||||
print("Error setting up machine: \(error)")
|
||||
return true
|
||||
}
|
||||
if let inputText = textField.text {
|
||||
do {
|
||||
outputTextField.text = try machine.encode(inputText)
|
||||
} catch let error {
|
||||
print("Error encoding: \(error)")
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func textFieldShouldClear(textField: UITextField) -> Bool {
|
||||
print("textFieldShouldClear")
|
||||
if textField === inputTextField {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
//
|
||||
// ViewController.swift
|
||||
// Enigma
|
||||
//
|
||||
// Created by Eryn Wells on 2015-07-18.
|
||||
// Copyright © 2015 Eryn Wells. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class ViewController: UIViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
}
|
||||
|
||||
override func didReceiveMemoryWarning() {
|
||||
super.didReceiveMemoryWarning()
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue