swift编码规范
- 注: MARK顺序没有强制要求,但System API & Public API一般分别放在第一块和第二块。* 大致区分为以下几块:
如下: forKeyPath
func addObserver(_ observer: NSObject, forKeyPath path: String)
class MyViewController: UIViewController { // class stuff here } // MARK: - UITableViewDataSource extension MyViewController: UITableViewDataSource { // table view data source methods } // MARK: - UIScrollViewDelegate extension MyViewController: UIScrollViewDelegate { // scroll view delegate methods }
resource.request().onComplete { [weak self] response in guard let strongSelf = self else { return } let model = strongSelf.updateModel(response) strongSelf.updateUI(model) }