UIViewController란? An object that manages a view hierarchy for your UIKit app.
class UIViewController : UIResponder
// 뷰가 메모리에 올려지는 순간
// 뷰가 화면에 보여지기 전에 생성되는 단계
override func loadView()
// 뷰가 화면에 보여지겠소
override func viewWillAppear(_ animated: Bool)
A view controller’s main responsibilities include the following:
뷰 컨트롤러가 하는 일은?
Specify the views for a view controller using the loadView() method. In that method, create your view hierarchy programmatically and assign the root view of that hierarchy to the view controller’s view property.
메모리에 생긴다 = init
메모리에서 사라진다 = deinit
Figure 1 A sample navigation interface
A navigation controller object manages its child view controllers using an ordered array, known as the navigation stack. The first view controller in the array is the root view controller and represents the bottom of the stack. The last view controller in the array is the topmost item on the stack, and represents the view controller currently being displayed. You add and remove view controllers from the stack using segues or using the methods of this class. The user can also remove the topmost view controller using the back button in the navigation bar or using a left-edge swipe gesture.
UIStepper란? A control for incrementing or decrementing a value.
class UIStepper : UIControl
stepper의 옵션 중
Segue란? 하나의 Scene 으로부터 다른 Scene으로의 전환을 보여주는 연결
< Back
을 누르면 현재 viewcontroller가 pop된다.override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let destination = segue.destination
guard let svc = destination as? StockAddViewController else { return }
svc.juiceMachine = self.juiceMachine
}
자체 프로퍼티인 destination을 통해 해당 세그의 목적지 뷰 컨트롤러를 추출할 수 있음.
해당 뷰컨트롤러가 실제 존재하는지 미리 확인하는 작업이 guard let 구문.
출처: iOS) Segue by 붱이