-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
은행 창구 관리 앱 [Step4] 댄, 네로 #95
base: d_Nero
Are you sure you want to change the base?
Changes from 42 commits
56c2c88
5b0ae02
a21e079
3b44171
b8d525f
43db72a
2ec7cb2
ad8437f
ae48f1b
f255323
3cd19c1
41d88e8
dd79f7e
2e62808
fd8a9c1
654cccd
00187e2
2bafe84
fa87371
82472f2
3c336b3
e1d1558
f709997
0461bbf
3502fd6
f36b7a8
0cebdd0
2207cf9
53650f5
3b37435
f306750
07b3909
ad29120
06f64b3
fb61c29
725bde8
676d82b
5c2e1d7
66d7af2
b2802f7
d47f25c
b01de31
cd0f3ec
fdd4302
8f5aec0
628697e
49d27fa
d6227c1
799ad24
ed23e6c
9e6e9aa
ad16011
b354a43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// BankManagerUIApp - SceneDelegate.swift | ||
// Created by yagom. | ||
// Copyright © yagom academy. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class SceneDelegate: UIResponder, UIWindowSceneDelegate { | ||
var window: UIWindow? | ||
|
||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | ||
guard let windowScene = (scene as? UIWindowScene) else { return } | ||
window = UIWindow(windowScene: windowScene) | ||
window?.rootViewController = ViewController(dataSource: BankManager()) | ||
window?.makeKeyAndVisible() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// BankManagerUIApp - ViewController.swift | ||
// Created by yagom. | ||
// Copyright © yagom academy. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class ViewController: UIViewController { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 상속하지 않으니 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 수정했습니다! |
||
private let mainView: MainView | ||
private let dataSource: BankManager | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dataSource라는 네이밍은 어색한 것 같습니다. 차라리 manager가 나을 것 같아요. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 뷰에서 보여줘야 하는 데이터를 관장하고 있으니 dataSource 가 더 어울린다고 생각했었는데요. |
||
private var stopwatch: Timer? | ||
private var elapsedTime: TimeInterval = 0 | ||
|
||
init(dataSource: BankManager) { | ||
self.mainView = MainView() | ||
self.dataSource = dataSource | ||
super.init(nibName: nil, bundle: nil) | ||
dataSource.delegate = self.mainView | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. manager의 delegate 객체가 View가 되는 것은 View의 책임에 어울리지 않는 것 같은데, 어떻게 생각하시나요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. View 의 책임에 어울리지 않는다는 점에 동의합니다. |
||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
view = mainView | ||
view.backgroundColor = .white | ||
} | ||
|
||
@objc func addCustomerButtonTapped() { | ||
countElapsedTime() | ||
dataSource.addCustomer() | ||
dataSource.startBankingProcess() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이렇게 되면 초기화 없이 고객을 추가할 경우 stopwatch에 타이머가 계속 할당되지 않나요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 타이머를 아예 새롭게 수정하여 문제를 해결했습니다. |
||
} | ||
|
||
@objc func resetService() { | ||
dataSource.reset() | ||
if let timer = stopwatch { | ||
timer.invalidate() | ||
stopwatch = nil | ||
elapsedTime = 0 | ||
mainView.setTimer("업무시간 - 00:00:000") | ||
} | ||
} | ||
|
||
func countElapsedTime() { | ||
stopwatch = Timer.scheduledTimer(withTimeInterval: 0.005, repeats: true) { timer in | ||
self.elapsedTime += timer.timeInterval | ||
let minutes = Int(self.elapsedTime) / 60 | ||
let seconds = Int(self.elapsedTime) % 60 | ||
let milliseconds = Int(self.elapsedTime * 1000) % 1000 | ||
|
||
let timeString = String(format: "%02d:%02d:%03d", minutes, seconds, milliseconds) | ||
self.mainView.setTimer("업무시간 - \(timeString)") | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 타이머는 어떻게 동작할까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Timer 클래스는 일정한 시간이 지날 때마다 타겟이 되는 객체에 메시지를 전송합니다. 말씀해주신 RunLoop 는 추가 공부가 필요한 것 같아 문서를 읽는 중입니다. |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 구조가 CustomView가 ViewController에 직접 접근하여 버튼 액션에 대한 기능을 사용하고 있는데, ViewController의 메서드들을 접근제한자 없이 공개적으로 사용하는 것 보단, View의 컴포넌트(버튼 등)을 오픈해놓은 것이 더 나을 것 같은데, 어떻게 생각하시나요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 코드를 수정하면서 질문 주실때와 상황이 달라진건지 제가 조금 헷갈립니다만, |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
목적에 맞는 네이밍으로 수정부탁드립니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MainViewController 로 수정했습니다.