生命周期 Live Cycle
程式碼撰寫須依照生命週期之執行順序
需使用 "MARK:-"分隔各個group
// MARK: - Lifecycle
// MARK: - IBActions
// MARK: - Public
// MARK: - Private
// MARK: - Protocol conformance
// MARK: - UITableViewDataSource
// MARK: - UITableViewDelegate
// MARK: - UITextFieldDelegate
// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - IBActions
@IBAction func onSubmit(_ sender: Any) {
}
@IBAction func onReload(_ sender: Any) {
}
// MARK: - Public
public func publicFunction() {
}
// MARK: - Private
func privateMethod() {
}
// MARK: - Protocol conformance
// MARK: - UITableViewDataSource
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
// MARK: - UITableViewDelegate
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
// MARK: - UITextFieldDelegate
func textFieldDidBeginEditing(_ textField: UITextField) {
}