From ff0cf30cc0ce067547e00c8bd1d98b3b577e08ea Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 19 Jul 2015 15:52:14 -0700 Subject: [PATCH] Add RotorViewController --- Enigma.xcodeproj/project.pbxproj | 8 ++++++ Enigma/RotorViewController.swift | 45 ++++++++++++++++++++++++++++++++ Enigma/RotorViewController.xib | 35 +++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 Enigma/RotorViewController.swift create mode 100644 Enigma/RotorViewController.xib diff --git a/Enigma.xcodeproj/project.pbxproj b/Enigma.xcodeproj/project.pbxproj index ed054ba..b8a7522 100644 --- a/Enigma.xcodeproj/project.pbxproj +++ b/Enigma.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + C027A7751B5C5ED80021FF3A /* RotorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C027A7731B5C5ED80021FF3A /* RotorViewController.swift */; }; + C027A7761B5C5ED80021FF3A /* RotorViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C027A7741B5C5ED80021FF3A /* RotorViewController.xib */; }; C04D337F1B5B3F6100E2888E /* Machine.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04D337E1B5B3F6100E2888E /* Machine.swift */; }; C0DA3A911B5AACB300D8D68E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DA3A901B5AACB300D8D68E /* AppDelegate.swift */; }; C0DA3A931B5AACB300D8D68E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DA3A921B5AACB300D8D68E /* ViewController.swift */; }; @@ -36,6 +38,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + C027A7731B5C5ED80021FF3A /* RotorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RotorViewController.swift; sourceTree = ""; }; + C027A7741B5C5ED80021FF3A /* RotorViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RotorViewController.xib; sourceTree = ""; }; C04D337E1B5B3F6100E2888E /* Machine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Machine.swift; sourceTree = ""; }; C0DA3A8D1B5AACB300D8D68E /* Enigma.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Enigma.app; sourceTree = BUILT_PRODUCTS_DIR; }; C0DA3A901B5AACB300D8D68E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -109,6 +113,8 @@ C0DA3A9C1B5AACB300D8D68E /* Info.plist */, C0DA3ABE1B5AB49200D8D68E /* Components.swift */, C04D337E1B5B3F6100E2888E /* Machine.swift */, + C027A7731B5C5ED80021FF3A /* RotorViewController.swift */, + C027A7741B5C5ED80021FF3A /* RotorViewController.xib */, ); path = Enigma; sourceTree = ""; @@ -235,6 +241,7 @@ buildActionMask = 2147483647; files = ( C0DA3A9B1B5AACB300D8D68E /* LaunchScreen.storyboard in Resources */, + C027A7761B5C5ED80021FF3A /* RotorViewController.xib in Resources */, C0DA3A981B5AACB300D8D68E /* Assets.xcassets in Resources */, C0DA3A961B5AACB300D8D68E /* Main.storyboard in Resources */, ); @@ -263,6 +270,7 @@ files = ( C04D337F1B5B3F6100E2888E /* Machine.swift in Sources */, C0DA3ABF1B5AB49200D8D68E /* Components.swift in Sources */, + C027A7751B5C5ED80021FF3A /* RotorViewController.swift in Sources */, C0DA3A931B5AACB300D8D68E /* ViewController.swift in Sources */, C0DA3A911B5AACB300D8D68E /* AppDelegate.swift in Sources */, ); diff --git a/Enigma/RotorViewController.swift b/Enigma/RotorViewController.swift new file mode 100644 index 0000000..360799e --- /dev/null +++ b/Enigma/RotorViewController.swift @@ -0,0 +1,45 @@ +// +// RotorViewController.swift +// Enigma +// +// Created by Eryn Wells on 2015-07-19. +// Copyright © 2015 Eryn Wells. All rights reserved. +// + +import UIKit + +class RotorViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate { + @IBOutlet weak var titleLabel: UILabel! + @IBOutlet weak var rotorPickerView: UIPickerView! + + let rotor: Rotor + + init(rotor: Rotor) { + self.rotor = rotor + super.init(nibName: nil, bundle: nil) + } + + required init(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func viewDidLoad() { + super.viewDidLoad() + } + + // MARK: - UIPickerViewDataSource + + func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int { + return 1 + } + + func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { + return Rotor.alphabet.count + } + + // MARK: - UIPickerViewDelegate + + func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { + return String(Rotor.alphabet[row]) + } +} diff --git a/Enigma/RotorViewController.xib b/Enigma/RotorViewController.xib new file mode 100644 index 0000000..1369f55 --- /dev/null +++ b/Enigma/RotorViewController.xib @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +