How to use MARK: in iOS Swift ?

We can write code annotation so that when we see the Minimap, it will list out functions & vars of the project in sectioned manner. This will speedup to jump the desired piece of code.
At Minimum we can apply the // MARK:  — ViewLifeCycle It will look like below image

For the Code

    //MARK:  -- ViewLifeCycle

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }


}
// MARK:  -- UITableViewDataSource
extension ViewController : UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 0
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        return UITableViewCell()
    }
}

// MARK: Here is -- UITableViewDelegate
extension ViewController: UITableViewDelegate {
    
}

//TODO: - To do block A TODO  reminder ...
extension ViewController {
    func makeAPICall() {}
}


//FIXME: - Bug fix block... A bug fix reminder ...
extension ViewController {
    func bugfix() {}
}

So we can also use additional markup based upon need like //TODO: To do block //FIXME: – Bug fix block.

Leave a Comment

Your email address will not be published. Required fields are marked *