From 68927c44055ab44a4aeb8e64214e667a9693a627 Mon Sep 17 00:00:00 2001 From: Ari Date: Mon, 25 Oct 2021 17:08:59 +0900 Subject: [PATCH 01/17] =?UTF-8?q?feat:=20=EC=A5=AC=EC=8A=A4=20=EC=A3=BC?= =?UTF-8?q?=EB=AC=B8=EB=B2=84=ED=8A=BC=20=ED=84=B0=EC=B9=98=20=EC=8B=9C=20?= =?UTF-8?q?Alret=20=ED=91=9C=EC=8B=9C=EB=90=98=EB=8A=94=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Juice 타입 rawValue 추가후 CustomStringConvertible 프로토콜 채택 - JuiceMakerViewController 클래스 내부에 orderJuiceButtonTapped 메서드 구현 - JuiceMakerViewController 클래스 내부에 juiceCompletionAlret 메서드 구현 --- .../Controller/JuiceMakerViewController.swift | 33 +++++++++++++++++++ JuiceMaker/JuiceMaker/Model/JuiceMaker.swift | 20 ++++++----- .../View/Base.lproj/Main.storyboard | 23 ++++++++++++- 3 files changed, 67 insertions(+), 9 deletions(-) diff --git a/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift b/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift index ef8a163f6..77af1f10a 100644 --- a/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift +++ b/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift @@ -13,6 +13,39 @@ class JuiceMakerViewController: UIViewController { // Do any additional setup after loading the view. } + @IBAction func orderJuiceButtonTapped(_ sender: UIButton) { + let buttonText = sender.titleLabel?.text + + switch buttonText { + case "딸바쥬스 주문": + juiceCompletionAlret(juice: .strawberryBanana) + case "망키쥬스 주문": + juiceCompletionAlret(juice: .mangoKiwi) + case "딸기쥬스 주문": + juiceCompletionAlret(juice: .strawberry) + case "바나나쥬스 주문": + juiceCompletionAlret(juice: .banana) + case "파인애플쥬스 주문": + juiceCompletionAlret(juice: .pineapple) + case "키위쥬스 주문": + juiceCompletionAlret(juice: .kiwi) + case "망고쥬스 주문": + juiceCompletionAlret(juice: .mango) + default: + let alret = UIAlertController(title: "오류", message: "잘못된 접근입니다.", preferredStyle: .alert) + let cencel = UIAlertAction(title: "Cencel", style: .destructive, handler: nil) + alret.addAction(cencel) + present(alret, animated: true, completion: nil) + } + + } + + func juiceCompletionAlret(juice: Juice){ + let alret = UIAlertController(title: nil, message: "\(juice) 쥬스 나왔습니다! 맛있게 드세요!", preferredStyle: .alert) + let cancel = UIAlertAction(title: "Cancel", style: .destructive, handler: nil) + alret.addAction(cancel) + present(alret, animated: true, completion: nil) + } } diff --git a/JuiceMaker/JuiceMaker/Model/JuiceMaker.swift b/JuiceMaker/JuiceMaker/Model/JuiceMaker.swift index b567a3a35..149a30f7e 100644 --- a/JuiceMaker/JuiceMaker/Model/JuiceMaker.swift +++ b/JuiceMaker/JuiceMaker/Model/JuiceMaker.swift @@ -8,14 +8,18 @@ import Foundation fileprivate typealias Recipe = [FruitStore.Fruit: Int] -enum Juice { - case strawberry - case banana - case kiwi - case pineapple - case strawberryBanana - case mango - case mangoKiwi +enum Juice: String, CustomStringConvertible { + case strawberry = "딸기" + case banana = "바나나" + case kiwi = "키위" + case pineapple = "파인애플" + case strawberryBanana = "딸바" + case mango = "망고" + case mangoKiwi = "망키" + + var description: String { + return rawValue + } fileprivate var recipe: Recipe { switch self { diff --git a/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard b/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard index 9223a3913..64b66b00f 100644 --- a/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard +++ b/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard @@ -126,6 +126,9 @@ + + + @@ -150,6 +156,9 @@ + + + @@ -171,6 +183,9 @@ + + + @@ -189,6 +207,9 @@ + + + @@ -403,7 +424,6 @@ - @@ -416,6 +436,7 @@ + From c8f2ac66d9c3899461b31ada6b6c3376b4109a8f Mon Sep 17 00:00:00 2001 From: JT Date: Mon, 25 Oct 2021 20:28:51 +0900 Subject: [PATCH 02/17] =?UTF-8?q?feat:=20=EC=A3=BC=EB=AC=B8=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20=ED=84=B0=EC=B9=98=EC=8B=9C=20=EC=9E=AC=EA=B3=A0?= =?UTF-8?q?=EA=B0=80=20=EC=9E=88=EB=8A=94=20=EA=B2=BD=EC=9A=B0=EC=99=80=20?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=EA=B2=BD=EC=9A=B0=EC=97=90=20=EB=8C=80?= =?UTF-8?q?=ED=95=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - JuiceMakerViewController 클래스에 juiceMaker 프로퍼티 생성 - orderJuiceButtonTapped 메소드 로직 수정 - notificationAlert 메소드를 통해 버튼이 하나인 Alert를 보여주도록 구현 - outOfStockAlert 메소드를 통해 버튼이 2개인 Alert를 보여주도록 구현 - juiceCompletionAlert 메소드 삭제 (notificationAlert에 통합) --- .../Controller/JuiceMakerViewController.swift | 54 +++++++++++++------ .../JuiceMaker/Model/RequestError.swift | 2 +- .../View/Base.lproj/Main.storyboard | 2 +- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift b/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift index 77af1f10a..dfe6e8fa7 100644 --- a/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift +++ b/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift @@ -8,6 +8,8 @@ import UIKit class JuiceMakerViewController: UIViewController { + private let juiceMaker = JuiceMaker() + override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. @@ -15,36 +17,56 @@ class JuiceMakerViewController: UIViewController { @IBAction func orderJuiceButtonTapped(_ sender: UIButton) { let buttonText = sender.titleLabel?.text + let juice: Juice switch buttonText { case "딸바쥬스 주문": - juiceCompletionAlret(juice: .strawberryBanana) + juice = .strawberryBanana case "망키쥬스 주문": - juiceCompletionAlret(juice: .mangoKiwi) + juice = .mangoKiwi case "딸기쥬스 주문": - juiceCompletionAlret(juice: .strawberry) + juice = .strawberry case "바나나쥬스 주문": - juiceCompletionAlret(juice: .banana) + juice = .banana case "파인애플쥬스 주문": - juiceCompletionAlret(juice: .pineapple) + juice = .pineapple case "키위쥬스 주문": - juiceCompletionAlret(juice: .kiwi) + juice = .kiwi case "망고쥬스 주문": - juiceCompletionAlret(juice: .mango) + juice = .mango default: - let alret = UIAlertController(title: "오류", message: "잘못된 접근입니다.", preferredStyle: .alert) - let cencel = UIAlertAction(title: "Cencel", style: .destructive, handler: nil) - alret.addAction(cencel) - present(alret, animated: true, completion: nil) + notificationAlert(message: "잘못된 접근입니다.") + return } + do { + try juiceMaker.mixFruit(juice: juice) + } catch RequestError.fruitStockOut { + outOfStockAlert() + } catch let error as RequestError { + notificationAlert(message: error.errorDescription) + } catch { + notificationAlert(message: "잘못된 접근입니다.") + } } - func juiceCompletionAlret(juice: Juice){ - let alret = UIAlertController(title: nil, message: "\(juice) 쥬스 나왔습니다! 맛있게 드세요!", preferredStyle: .alert) - let cancel = UIAlertAction(title: "Cancel", style: .destructive, handler: nil) - alret.addAction(cancel) - present(alret, animated: true, completion: nil) + func notificationAlert(message: String, title: String = "OK") { + let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert) + let cancel = UIAlertAction(title: title, style: .cancel, handler: nil) + alert.addAction(cancel) + present(alert, animated: true, completion: nil) + } + + func outOfStockAlert() { + let alert = UIAlertController(title: nil, message: "재료가 모자라요. 재고를 수정할까요?", preferredStyle: .alert) + let noAction = UIAlertAction(title: "아니오", style: .cancel, handler: nil) + let yesAction = UIAlertAction(title: "네", style: .default) { _ in + guard let viewController = self.storyboard?.instantiateViewController(withIdentifier: "FruitStoreView") else { return } + self.present(viewController, animated: true, completion: nil) + } + alert.addAction(noAction) + alert.addAction(yesAction) + present(alert, animated: true, completion: nil) } } diff --git a/JuiceMaker/JuiceMaker/Model/RequestError.swift b/JuiceMaker/JuiceMaker/Model/RequestError.swift index 8c1afcf5e..a7480259a 100644 --- a/JuiceMaker/JuiceMaker/Model/RequestError.swift +++ b/JuiceMaker/JuiceMaker/Model/RequestError.swift @@ -7,7 +7,7 @@ import Foundation -enum RequestError: Error, LocalizedError { +enum RequestError: Error { case wrongCount case fruitNotFound case fruitStockOut diff --git a/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard b/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard index 64b66b00f..192904579 100644 --- a/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard +++ b/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard @@ -424,7 +424,7 @@ - + From e083fff4f2a9d7a72e49f2996696c955254c266d Mon Sep 17 00:00:00 2001 From: Ari Date: Mon, 25 Oct 2021 21:38:54 +0900 Subject: [PATCH 03/17] =?UTF-8?q?feat:=20=EA=B3=BC=EC=9D=BC=EC=9D=98=20?= =?UTF-8?q?=EC=9E=AC=EA=B3=A0=EA=B0=80=20=EB=B0=94=EB=80=94=20=EB=95=8C=20?= =?UTF-8?q?=EB=A7=88=EB=8B=A4=20=ED=99=94=EB=A9=B4=EC=97=90=20=EB=B0=98?= =?UTF-8?q?=EC=98=81=EB=90=98=EB=8F=84=EB=A1=9D=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Notification.Name changedFruitStockNotification 추가 - FruitStore 타입 내부에 changeAmount 메서드에 Notification 발송 기능 추가 - JuiceMakerViewController 내부에 Label들을 업데이트 할 수 있도록 여러 메서드 추가 --- .../Controller/JuiceMakerViewController.swift | 56 ++++++++++++++++++- JuiceMaker/JuiceMaker/Model/FruitStore.swift | 12 ++++ .../View/Base.lproj/Main.storyboard | 7 +++ 3 files changed, 74 insertions(+), 1 deletion(-) diff --git a/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift b/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift index dfe6e8fa7..f0335f9f2 100644 --- a/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift +++ b/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift @@ -10,9 +10,62 @@ class JuiceMakerViewController: UIViewController { private let juiceMaker = JuiceMaker() + @IBOutlet weak var strawberryStock: UILabel! + @IBOutlet weak var bananaStock: UILabel! + @IBOutlet weak var pineappleStock: UILabel! + @IBOutlet weak var kiwiStock: UILabel! + @IBOutlet weak var mangoStock: UILabel! + + override func viewDidLoad() { super.viewDidLoad() - // Do any additional setup after loading the view. + uploadStocks() + + NotificationCenter.default.addObserver(self, selector: #selector(updateFruitStock(notification:)), name: .changedFruitStockNotification, object: nil) + } + + func uploadStocks() { + currentStockLabel(fruit: .strawberry, label: strawberryStock) + currentStockLabel(fruit: .banana, label: bananaStock) + currentStockLabel(fruit: .pineapple, label: pineappleStock) + currentStockLabel(fruit: .kiwi, label: kiwiStock) + currentStockLabel(fruit: .mango, label: mangoStock) + } + + + func currentStockLabel(fruit: FruitStore.Fruit, label: UILabel) { + do { + let stock = try FruitStore.shared.stock(fruit: fruit) + label.text = String(stock) + } catch let error as RequestError { + notificationAlert(message: error.errorDescription) + } catch { + notificationAlert(message: "알 수 없는 에러가 발생했습니다.") + } + } + + @objc func updateFruitStock(notification: Notification) { + // 수정된 과일과 과일의 재고갯수를 받아와서 label을 수정 + guard let fruit = notification.object as? FruitStore.Fruit else { + notificationAlert(message: "알 수 없는 에러가 발생했습니다.") + return + } + currentStockLabel(fruit: fruit, label: fruitlabel(of: fruit)) + } + + func fruitlabel(of fruit: FruitStore.Fruit) -> UILabel { + switch fruit { + case .strawberry: + return strawberryStock + case .banana: + return bananaStock + case .pineapple: + return pineappleStock + case .kiwi: + return kiwiStock + case .mango: + return mangoStock + } } @IBAction func orderJuiceButtonTapped(_ sender: UIButton) { @@ -41,6 +94,7 @@ class JuiceMakerViewController: UIViewController { do { try juiceMaker.mixFruit(juice: juice) + notificationAlert(message: "\(juice) 쥬스 나왔습니다! 맛있게 드세요!") } catch RequestError.fruitStockOut { outOfStockAlert() } catch let error as RequestError { diff --git a/JuiceMaker/JuiceMaker/Model/FruitStore.swift b/JuiceMaker/JuiceMaker/Model/FruitStore.swift index 0cef8ba68..3ecb36b7b 100644 --- a/JuiceMaker/JuiceMaker/Model/FruitStore.swift +++ b/JuiceMaker/JuiceMaker/Model/FruitStore.swift @@ -29,6 +29,13 @@ class FruitStore { self.fruitBasket = Dictionary(uniqueKeysWithValues: zip(allFruits, fruitscount)) } + func stock(fruit: Fruit) throws -> Int { + guard let fruitStock = fruitBasket[fruit] else { + throw RequestError.fruitNotFound + } + return fruitStock + } + func addFruitStock(fruit: Fruit, count: Int) throws { try changeAmount(count: count, of: fruit, by: +) } @@ -49,6 +56,8 @@ class FruitStore { } let newFruitCount = calculator(oldFruitCount, count) fruitBasket[fruit] = newFruitCount + + NotificationCenter.default.post(name: .changedFruitStockNotification, object: fruit) } func hasFruitStock(of fruit: Fruit, count fruitCountSubtracted: Int) -> Bool { @@ -58,3 +67,6 @@ class FruitStore { } +extension Notification.Name { + static let changedFruitStockNotification = Notification.Name("changeFruitStock") +} diff --git a/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard b/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard index 192904579..a5194baa3 100644 --- a/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard +++ b/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard @@ -243,6 +243,13 @@ + + + + + + + From 293f81135e1adef36b72abbd942b76c182e26ba1 Mon Sep 17 00:00:00 2001 From: JT Date: Tue, 26 Oct 2021 10:15:57 +0900 Subject: [PATCH 04/17] =?UTF-8?q?refactor:=20HIG=20=EC=A7=80=EC=B9=A8?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=9D=BC=20Alert=EC=9D=98=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=EC=A7=80=20=EB=AC=B8=EA=B5=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JuiceMaker/Controller/JuiceMakerViewController.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift b/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift index f0335f9f2..b4a469b4b 100644 --- a/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift +++ b/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift @@ -113,13 +113,13 @@ class JuiceMakerViewController: UIViewController { func outOfStockAlert() { let alert = UIAlertController(title: nil, message: "재료가 모자라요. 재고를 수정할까요?", preferredStyle: .alert) - let noAction = UIAlertAction(title: "아니오", style: .cancel, handler: nil) - let yesAction = UIAlertAction(title: "네", style: .default) { _ in + let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) + let okAction = UIAlertAction(title: "OK", style: .default) { _ in guard let viewController = self.storyboard?.instantiateViewController(withIdentifier: "FruitStoreView") else { return } self.present(viewController, animated: true, completion: nil) } - alert.addAction(noAction) - alert.addAction(yesAction) + alert.addAction(cancelAction) + alert.addAction(okAction) present(alert, animated: true, completion: nil) } From a560ab2f3c0c8ce196aa66a6bb507e874e0ff577 Mon Sep 17 00:00:00 2001 From: Ari Date: Tue, 26 Oct 2021 10:19:18 +0900 Subject: [PATCH 05/17] =?UTF-8?q?refactor:=20Fruit=ED=83=80=EC=9E=85?= =?UTF-8?q?=EC=9D=84=20FruitStore=20=EB=82=B4=EB=B6=80=EC=97=90=EC=84=9C?= =?UTF-8?q?=20=EC=99=B8=EB=B6=80=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/JuiceMakerViewController.swift | 6 +++--- JuiceMaker/JuiceMaker/Model/FruitStore.swift | 18 ++++++++---------- JuiceMaker/JuiceMaker/Model/JuiceMaker.swift | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift b/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift index b4a469b4b..7f3f619ea 100644 --- a/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift +++ b/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift @@ -33,7 +33,7 @@ class JuiceMakerViewController: UIViewController { } - func currentStockLabel(fruit: FruitStore.Fruit, label: UILabel) { + func currentStockLabel(fruit: Fruit, label: UILabel) { do { let stock = try FruitStore.shared.stock(fruit: fruit) label.text = String(stock) @@ -46,14 +46,14 @@ class JuiceMakerViewController: UIViewController { @objc func updateFruitStock(notification: Notification) { // 수정된 과일과 과일의 재고갯수를 받아와서 label을 수정 - guard let fruit = notification.object as? FruitStore.Fruit else { + guard let fruit = notification.object as? Fruit else { notificationAlert(message: "알 수 없는 에러가 발생했습니다.") return } currentStockLabel(fruit: fruit, label: fruitlabel(of: fruit)) } - func fruitlabel(of fruit: FruitStore.Fruit) -> UILabel { + func fruitlabel(of fruit: Fruit) -> UILabel { switch fruit { case .strawberry: return strawberryStock diff --git a/JuiceMaker/JuiceMaker/Model/FruitStore.swift b/JuiceMaker/JuiceMaker/Model/FruitStore.swift index 3ecb36b7b..ec185a441 100644 --- a/JuiceMaker/JuiceMaker/Model/FruitStore.swift +++ b/JuiceMaker/JuiceMaker/Model/FruitStore.swift @@ -8,18 +8,16 @@ import Foundation private let defaultFruitCount = 10 +enum Fruit: CaseIterable { + case strawberry + case banana + case pineapple + case kiwi + case mango +} + class FruitStore { - static let shared: FruitStore = FruitStore() - - enum Fruit: CaseIterable { - case strawberry - case banana - case pineapple - case kiwi - case mango - } - private var fruitBasket: [Fruit: Int] init(count: Int = defaultFruitCount) { diff --git a/JuiceMaker/JuiceMaker/Model/JuiceMaker.swift b/JuiceMaker/JuiceMaker/Model/JuiceMaker.swift index 149a30f7e..63d8321d2 100644 --- a/JuiceMaker/JuiceMaker/Model/JuiceMaker.swift +++ b/JuiceMaker/JuiceMaker/Model/JuiceMaker.swift @@ -6,7 +6,7 @@ import Foundation -fileprivate typealias Recipe = [FruitStore.Fruit: Int] +fileprivate typealias Recipe = [Fruit: Int] enum Juice: String, CustomStringConvertible { case strawberry = "딸기" From 57031d73624d14a8574f82e9914d2bfb1207bb98 Mon Sep 17 00:00:00 2001 From: JT Date: Tue, 26 Oct 2021 10:22:43 +0900 Subject: [PATCH 06/17] =?UTF-8?q?refactor:=20JuiceMakerViewController?= =?UTF-8?q?=EC=9D=98=20UILabel=20=ED=94=84=EB=A1=9C=ED=8D=BC=ED=8B=B0=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/JuiceMakerViewController.swift | 30 ++--- .../View/Base.lproj/Main.storyboard | 118 +++++++++--------- 2 files changed, 73 insertions(+), 75 deletions(-) diff --git a/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift b/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift index 7f3f619ea..fd6bcd3f8 100644 --- a/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift +++ b/JuiceMaker/JuiceMaker/Controller/JuiceMakerViewController.swift @@ -10,11 +10,11 @@ class JuiceMakerViewController: UIViewController { private let juiceMaker = JuiceMaker() - @IBOutlet weak var strawberryStock: UILabel! - @IBOutlet weak var bananaStock: UILabel! - @IBOutlet weak var pineappleStock: UILabel! - @IBOutlet weak var kiwiStock: UILabel! - @IBOutlet weak var mangoStock: UILabel! + @IBOutlet weak var strawberryStockLabel: UILabel! + @IBOutlet weak var bananaStockLabel: UILabel! + @IBOutlet weak var pineappleStockLabel: UILabel! + @IBOutlet weak var kiwiStockLabel: UILabel! + @IBOutlet weak var mangoStockLabel: UILabel! override func viewDidLoad() { @@ -25,11 +25,11 @@ class JuiceMakerViewController: UIViewController { } func uploadStocks() { - currentStockLabel(fruit: .strawberry, label: strawberryStock) - currentStockLabel(fruit: .banana, label: bananaStock) - currentStockLabel(fruit: .pineapple, label: pineappleStock) - currentStockLabel(fruit: .kiwi, label: kiwiStock) - currentStockLabel(fruit: .mango, label: mangoStock) + currentStockLabel(fruit: .strawberry, label: strawberryStockLabel) + currentStockLabel(fruit: .banana, label: bananaStockLabel) + currentStockLabel(fruit: .pineapple, label: pineappleStockLabel) + currentStockLabel(fruit: .kiwi, label: kiwiStockLabel) + currentStockLabel(fruit: .mango, label: mangoStockLabel) } @@ -56,15 +56,15 @@ class JuiceMakerViewController: UIViewController { func fruitlabel(of fruit: Fruit) -> UILabel { switch fruit { case .strawberry: - return strawberryStock + return strawberryStockLabel case .banana: - return bananaStock + return bananaStockLabel case .pineapple: - return pineappleStock + return pineappleStockLabel case .kiwi: - return kiwiStock + return kiwiStockLabel case .mango: - return mangoStock + return mangoStockLabel } } diff --git a/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard b/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard index a5194baa3..8a07fd56d 100644 --- a/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard +++ b/JuiceMaker/JuiceMaker/View/Base.lproj/Main.storyboard @@ -1,9 +1,7 @@ - - + - - + @@ -15,23 +13,23 @@ - + - + - + - + - + - + - + - + - +